[settings] Fix form display and show widgets
This commit is contained in:
@ -23,3 +23,8 @@ class ProfileFormView(LoginRequiredMixin, FormView):
|
||||
def form_valid(self, form):
|
||||
form.save()
|
||||
return super(ProfileFormView, self).form_valid(form)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["user_id"] = self.request.user.id
|
||||
return context
|
||||
|
||||
@ -38,6 +38,22 @@ input:focus {
|
||||
border-color: #007bff;
|
||||
box-shadow: 0 0 5px rgba(0, 123, 255, 0.2);
|
||||
}
|
||||
|
||||
.widget-links {
|
||||
margin: 10px 0 20px 20px;
|
||||
padding: 10px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.widget-links ul {
|
||||
margin: 5px 0 0 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.widget-links li {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@ -47,7 +63,36 @@ input:focus {
|
||||
{% block title %}Settings{% endblock %}
|
||||
{% block details %}
|
||||
<form method="post">{% csrf_token %}
|
||||
{{form.as_p}}
|
||||
{% for field in form %}
|
||||
{% if field.name == "enable_public_widgets" %}
|
||||
<p>
|
||||
{{ field }}
|
||||
{{ field.label_tag }}
|
||||
{% if field.errors %}
|
||||
<span class="error">{{ field.errors }}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% if user_id %}
|
||||
<div class="widget-links">
|
||||
<p><strong>Available Widgets:</strong></p>
|
||||
<ul>
|
||||
<li><a href="{% url 'scrobbles:embeddable-top-artists' user_id %}">Top Artists</a></li>
|
||||
<li><a href="{% url 'scrobbles:embeddable-top-board-games-week' user_id %}">Top Board Games (Week)</a></li>
|
||||
<li><a href="{% url 'scrobbles:embeddable-top-board-games-month' user_id %}">Top Board Games (Month)</a></li>
|
||||
<li><a href="{% url 'scrobbles:embeddable-top-board-games-year' user_id %}">Top Board Games (Year)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<p>
|
||||
{{ field.label_tag }}
|
||||
{{ field }}
|
||||
{% if field.errors %}
|
||||
<span class="error">{{ field.errors }}</span>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<input type="submit" value="Save">
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user