objects management forms and templates reviewed
This commit is contained in:
parent
b5f1cea474
commit
b94039e0e8
|
@ -5,7 +5,9 @@ from .models import Announce, Category
|
|||
class AnnounceForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Announce
|
||||
exclude = ('publication_time', 'expiration_time')
|
||||
|
||||
class CategoryForm(forms.ModelForm):
|
||||
class Meta:
|
||||
fields = ('name', )
|
||||
model = Category
|
||||
|
|
|
@ -198,11 +198,11 @@ div.user a.logout:before {
|
|||
width: 20px;
|
||||
}
|
||||
|
||||
.actions .edit:before {
|
||||
.edit:before {
|
||||
content: '\f044';
|
||||
}
|
||||
|
||||
.actions .delete:before {
|
||||
.delete:before {
|
||||
content: '\f1f8';
|
||||
}
|
||||
|
||||
|
@ -247,12 +247,10 @@ div.user a.logout:before {
|
|||
|
||||
.categories a, #management > span a {
|
||||
color: #000;
|
||||
border: 1px solid #666;
|
||||
padding: 1px 3px;
|
||||
margin: 0;
|
||||
font-weight: bold;
|
||||
font-size: .75em;
|
||||
background: #eee;
|
||||
}
|
||||
|
||||
a.add:before {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
{% extends "corbo/manage.html" %}
|
||||
{% load i18n %}
|
||||
{% block content %}
|
||||
<form method="post">
|
||||
<h5>
|
||||
{% blocktrans with title=object.title %}
|
||||
Are you sure you want to delete the announce "{{ title }}" ?
|
||||
{% endblocktrans %}
|
||||
</h5>
|
||||
{% csrf_token %}
|
||||
<button>{% trans "Delete" %}</button>
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -0,0 +1,14 @@
|
|||
{% extends "corbo/manage.html" %}
|
||||
{% load i18n %}
|
||||
{% block content %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<h5>
|
||||
{% blocktrans with name=object.name %}
|
||||
Are you sure you want to delete category "{{ name }}"?
|
||||
{% endblocktrans %}
|
||||
</h5>
|
||||
<p class="text_preview">{% trans "All its announces of will be also deleted" %}</p>
|
||||
<button>{% trans "Delete" %}</button>
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -15,7 +15,12 @@
|
|||
<option value='{{ category.id }}'{% if category_id == category.id %} selected{% endif %}>{{ category }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<span><a class="icon add" href="{% url "add_category" %}" rel="popup">{% trans "add category" %}</a></span>
|
||||
<span>
|
||||
{% if category_id %}
|
||||
<a class="icon edit" href="{% url "edit_category" category_id %}" rel="popup" title="{% trans "edit category" %}"></a>
|
||||
<a class="icon delete" href="{% url "delete_category" category_id %}" rel="popup" title="{% trans "delete category" %}"></a>
|
||||
{% endif %}
|
||||
<a class="icon add" href="{% url "add_category" %}" rel="popup" title="{% trans "add category" %}"></a></span>
|
||||
</div>
|
||||
<div id="management">
|
||||
<h4>{% trans "Announces" %}</h4>
|
||||
|
|
|
@ -25,6 +25,7 @@ add_announce = AnnounceCreateView.as_view()
|
|||
|
||||
class AnnounceEditView(UpdateView):
|
||||
model = models.Announce
|
||||
form_class = AnnounceForm
|
||||
success_url = '../..'
|
||||
|
||||
edit_announce = AnnounceEditView.as_view()
|
||||
|
@ -47,13 +48,15 @@ class CategoryCreateView(CreateView):
|
|||
add_category = CategoryCreateView.as_view()
|
||||
|
||||
class CategoryEditView(UpdateView):
|
||||
form_class = CategoryForm
|
||||
model = models.Category
|
||||
success_url = '..'
|
||||
success_url = '../..'
|
||||
|
||||
edit_category = CategoryEditView.as_view()
|
||||
|
||||
class DeleteView(DeleteView):
|
||||
model = models.Category
|
||||
success_url = '../..'
|
||||
|
||||
delete_category = DeleteView.as_view()
|
||||
|
||||
|
|
Reference in New Issue