diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-02-28 16:55:48 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-02-28 16:55:48 +0100 |
commit | 32898e97c51c8567798c9518bf7c1934fabd5371 (patch) | |
tree | 875a2ccc36091aa619a915df2445399edb08af7d | |
parent | 5e56ea6cddb3cc97892948239dc7b9adbe6a0ec4 (diff) | |
download | Chimère-32898e97c51c8567798c9518bf7c1934fabd5371.tar.bz2 Chimère-32898e97c51c8567798c9518bf7c1934fabd5371.zip |
Move the submit message to the edit page
-rw-r--r-- | chimere/forms.py | 4 | ||||
-rw-r--r-- | chimere/templates/chimere/blocks/submited.html | 5 | ||||
-rw-r--r-- | chimere/templates/chimere/edit.html | 3 | ||||
-rw-r--r-- | chimere/templates/chimere/edit_route.html | 3 | ||||
-rw-r--r-- | chimere/templates/chimere/submited.html | 16 | ||||
-rw-r--r-- | chimere/templatetags/chimere_tags.py | 7 | ||||
-rw-r--r-- | chimere/urls.py | 10 | ||||
-rw-r--r-- | chimere/views.py | 69 |
8 files changed, 59 insertions, 58 deletions
diff --git a/chimere/forms.py b/chimere/forms.py index 638e67e..e22c9c7 100644 --- a/chimere/forms.py +++ b/chimere/forms.py @@ -203,8 +203,8 @@ class RouteAdminForm(forms.ModelForm): keys['initial'] = property_dct super(RouteAdminForm, self).__init__(*args, **keys) if settings.CHIMERE_DAYS_BEFORE_EVENT: - self.fields['start_date'].widget = AdminDateWidget() - self.fields['end_date'].widget = AdminDateWidget() + self.fields['start_date'].widget = DatePickerWidget() + self.fields['end_date'].widget = DatePickerWidget() def save(self, *args, **keys): """ diff --git a/chimere/templates/chimere/blocks/submited.html b/chimere/templates/chimere/blocks/submited.html new file mode 100644 index 0000000..0def505 --- /dev/null +++ b/chimere/templates/chimere/blocks/submited.html @@ -0,0 +1,5 @@ +{% load i18n %} + <fieldset class='edit'> + <legend>{% trans "Thank you" %}</legend> + <p>{% trans "Your proposition has been submited. A moderator will treat your submission shortly. Thanks!" %}</p> + </fieldset> diff --git a/chimere/templates/chimere/edit.html b/chimere/templates/chimere/edit.html index d087f1a..0616694 100644 --- a/chimere/templates/chimere/edit.html +++ b/chimere/templates/chimere/edit.html @@ -14,9 +14,10 @@ {% endblock %} {% block content %} + {% if submited %}{% submited %}{% endif %} {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %} <fieldset class='edit'> - <legend>{% trans "Add a new site" %}</legend> + <legend>{% trans "Add/modify a site" %}</legend> <p>* {% trans "indicates a mandatory field" %}</p> <form enctype="multipart/form-data" method='post' action='.'> {% csrf_token %} diff --git a/chimere/templates/chimere/edit_route.html b/chimere/templates/chimere/edit_route.html index 1088f2b..c1def64 100644 --- a/chimere/templates/chimere/edit_route.html +++ b/chimere/templates/chimere/edit_route.html @@ -14,9 +14,10 @@ {% endblock %} {% block content %} + {% if submited %}{% submited %}{% endif %} {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %} <fieldset class='edit'> - <legend>{% trans "Add a new route" %}</legend> + <legend>{% trans "Add/modify a route" %}</legend> <p>* {% trans "indicates a mandatory field" %}</p> <form enctype="multipart/form-data" method='post' action='.'> {% csrf_token %} diff --git a/chimere/templates/chimere/submited.html b/chimere/templates/chimere/submited.html deleted file mode 100644 index 882f75b..0000000 --- a/chimere/templates/chimere/submited.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends "chimere/base.html" %} -{% load i18n chimere_tags %} -{% block extra_head %} - {{ block.super }} - {{ form.media }} - {% head_jquery %} -{% endblock %} -{% block message_map %}{% endblock %} -{% block content %} - {{ block.super }} - <fieldset class='edit'> - <legend>{% trans "Thank you" %}</legend> - <p>{% trans "Your proposition has been submited. A moderator will treat your submission shortly. Thanks!" %}</p> - </fieldset> -{% endblock %} - diff --git a/chimere/templatetags/chimere_tags.py b/chimere/templatetags/chimere_tags.py index 8091d89..0df8100 100644 --- a/chimere/templatetags/chimere_tags.py +++ b/chimere/templatetags/chimere_tags.py @@ -21,6 +21,13 @@ def display_areas(context): "STATIC_URL": context["STATIC_URL"]} return context_data +@register.inclusion_tag('chimere/blocks/submited.html', takes_context=True) +def submited(context): + """ + Submited message. + """ + return {} + @register.inclusion_tag('chimere/blocks/welcome.html', takes_context=True) def display_news(context, display=False): """ diff --git a/chimere/urls.py b/chimere/urls.py index 8112570..f4d6157 100644 --- a/chimere/urls.py +++ b/chimere/urls.py @@ -36,16 +36,14 @@ urlpatterns = patterns('chimere.views', urlpatterns += patterns('chimere.views', url(r'^charte/?$', 'charte', name="charte"), url(r'^(?P<area_name>\w+)?/?contact/?$', 'contactus', name="contact"), - url(r'^(?P<area_name>\w+)?/?submited/(?P<action>\w+)/?$', 'submited', - name="submit"), url(r'^(?P<area_name>\w+)?/?edit/$', 'edit', name="edit"), - url(r'^(?P<area_name>\w+)?/?edit/(?P<item_id>\w+)/$', 'edit', - name="edit-item"), + url(r'^(?P<area_name>\w+)?/?edit/(?P<item_id>\w+)/(?P<submited>\w+)?$', + 'edit', name="edit-item"), url(r'^(?P<area_name>\w+)?/?edit-route/$', 'editRoute', name="editroute"), - url(r'^(?P<area_name>\w+)?/?edit-route/(?P<item_id>\w+)/$', 'editRoute', - name="editroute-item"), + url(r'^(?P<area_name>\w+)?/?edit-route/(?P<item_id>\w+)/(?P<submited>\w+)?$', + 'editRoute', name="editroute-item"), url(r'^(?P<area_name>\w+)?/?getDetail/(?P<marker_id>\d+)/?$', 'getDetail', name="get_detail"), url(r'^(?P<area_name>\w+)?/?getDescriptionDetail/?(?P<category_id>\d+)/?$', diff --git a/chimere/views.py b/chimere/views.py index c6fba50..9189caa 100644 --- a/chimere/views.py +++ b/chimere/views.py @@ -153,7 +153,8 @@ def get_edit_page(redirect_url, item_cls, item_form): notifySubmission(item) response_dct = get_base_response(area_name) return redirect(redirect_url + '-item', - area_name if area_name else '', item.ref_item.pk),\ + area_name if area_name else '', item.ref_item.pk, + 'submited'),\ None else: form = item_form(instance=init_item) @@ -162,7 +163,7 @@ def get_edit_page(redirect_url, item_cls, item_form): get_edit_marker = get_edit_page('chimere:edit', Marker, MarkerForm) -def edit(request, area_name="", item_id=None): +def edit(request, area_name="", item_id=None, submited=False): """ Edition page """ @@ -173,21 +174,23 @@ def edit(request, area_name="", item_id=None): # get the "manualy" declared_fields. Ie: properties declared_fields = form.declared_fields.keys() - response_dct.update({'actions':actions, - 'action_selected':('contribute', 'edit'), - 'error_message':'', - 'map_layer':settings.CHIMERE_MAP_LAYER, - 'form':form, - 'dated':settings.CHIMERE_DAYS_BEFORE_EVENT, - 'extra_head':form.media, - 'marker_id':item_id, - 'sub_categories':SubCategory.getAvailable(['M', 'B'], - area_name), - 'point_widget':PointChooserWidget().render('point', - init_item.point if init_item else None, - area_name=area_name), - 'properties':declared_fields, - }) + response_dct.update({ + 'actions':actions, + 'action_selected':('contribute', 'edit'), + 'error_message':'', + 'map_layer':settings.CHIMERE_MAP_LAYER, + 'form':form, + 'dated':settings.CHIMERE_DAYS_BEFORE_EVENT, + 'extra_head':form.media, + 'marker_id':item_id, + 'sub_categories':SubCategory.getAvailable(['M', 'B'], + area_name), + 'point_widget':PointChooserWidget().render('point', + init_item.point if init_item else None, + area_name=area_name), + 'properties':declared_fields, + 'submited':submited + }) # manualy populate the custom widget if 'subcategory' in form.data and form.data['subcategory']: response_dct['current_category'] = int(form.data['subcategory']) @@ -258,7 +261,7 @@ def processRouteFile(request, area_name='', file_id=None): get_edit_route = get_edit_page('chimere:editroute', Route, RouteForm) -def editRoute(request, area_name="", item_id=None): +def editRoute(request, area_name="", item_id=None, submited=False): """ Route edition page """ @@ -269,20 +272,22 @@ def editRoute(request, area_name="", item_id=None): # get the "manualy" declared_fields. Ie: properties declared_fields = form.declared_fields.keys() - response_dct.update({'actions':actions, - 'action_selected':('contribute', 'edit-route'), - 'error_message':'', - 'map_layer':settings.CHIMERE_MAP_LAYER, - 'form':form, - 'dated':settings.CHIMERE_DAYS_BEFORE_EVENT, - 'extra_head':form.media, - 'sub_categories':SubCategory.getAvailable(['R', 'B'], - area_name), - 'route_widget':RouteChooserWidget().render('route', - init_item.route if init_item else None, - area_name=area_name, routefile_id='',), - 'properties':declared_fields - }) + response_dct.update({ + 'actions':actions, + 'action_selected':('contribute', 'edit-route'), + 'error_message':'', + 'map_layer':settings.CHIMERE_MAP_LAYER, + 'form':form, + 'dated':settings.CHIMERE_DAYS_BEFORE_EVENT, + 'extra_head':form.media, + 'sub_categories':SubCategory.getAvailable(['R', 'B'], + area_name), + 'route_widget':RouteChooserWidget().render('route', + init_item.route if init_item else None, + area_name=area_name, routefile_id='',), + 'properties':declared_fields, + 'submited':submited + }) # manualy populate the custom widget if 'subcategory' in form.data and form.data['subcategory']: response_dct['current_category'] = int(form.data['subcategory']) |