diff options
-rw-r--r-- | chimere/actions.py | 12 | ||||
-rw-r--r-- | chimere/forms.py | 3 | ||||
-rw-r--r-- | chimere/urls.py | 6 | ||||
-rw-r--r-- | chimere/views.py | 26 |
4 files changed, 33 insertions, 14 deletions
diff --git a/chimere/actions.py b/chimere/actions.py index ac2bbaf..1fac738 100644 --- a/chimere/actions.py +++ b/chimere/actions.py @@ -36,18 +36,19 @@ class Action: try: self.url = reverse( self.path, - args=[area_name if area_name else ''] + self.extra_url_args) + args=[area_name + '/' if area_name else ''] + + self.extra_url_args) except NoReverseMatch: # backward url management self.url = reverse( self.path, - args=[area_name + '/' if area_name else ''] - + self.extra_url_args) + args=[area_name if area_name else ''] + self.extra_url_args) default_actions = [ (Action('view', 'chimere:index', _('View')), []), (Action('contribute', 'chimere:edit', _('Contribute')), - (Action('edit', 'chimere:edit', _('Add a new point of interest')), + (Action('edit-marker', 'chimere:editmarker', + _('Add a new point of interest')), Action('edit-route', 'chimere:editroute', _('Add a new route')), Action('edit-polygon', 'chimere:editpolygon', _('Add a new polygon'))), )] @@ -82,7 +83,8 @@ def actions(area_name=''): real_childs = [] for child_act in childs: if area: - if (child_act.id == 'edit' and not area.allow_point_edition) \ + if (child_act.id == 'edit-marker' + and not area.allow_point_edition) \ or (child_act.id == 'edit-route' and not area.allow_route_edition) \ or (child_act.id == 'edit-polygon' diff --git a/chimere/forms.py b/chimere/forms.py index e17e3c9..585cc85 100644 --- a/chimere/forms.py +++ b/chimere/forms.py @@ -294,9 +294,9 @@ class MarkerAdminFormBase(forms.ModelForm): if settings.CHIMERE_DAYS_BEFORE_EVENT: self.fields['start_date'].widget = DatePickerWidget() self.fields['end_date'].widget = DatePickerWidget() + self.fields['categories'].choices = [] if subcategories: self.fields['categories'].choices = subcategories - self.fields['categories'].choices = [] # auto select if there is only one category choices = list(self.fields['categories'].choices) self.fields['categories'].choices = choices @@ -468,6 +468,7 @@ class RouteAdminForm(forms.ModelForm): if settings.CHIMERE_DAYS_BEFORE_EVENT: self.fields['start_date'].widget = DatePickerWidget() self.fields['end_date'].widget = DatePickerWidget() + self.fields['categories'].choices = [] if subcategories: self.fields['categories'].choices = subcategories # not a clean way to filter properties... diff --git a/chimere/urls.py b/chimere/urls.py index e0153f0..b5fa815 100644 --- a/chimere/urls.py +++ b/chimere/urls.py @@ -99,8 +99,10 @@ urlpatterns += patterns( name="contact"), url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit/$', 'edit', name="edit"), - url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit/(?P<item_id>\w+)/' - r'(?P<submited>\w+)?$', 'edit', name="edit-item"), + url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-marker/' + r'(?P<submited>\w+)?$', 'editMarker', name="editmarker"), + url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-marker/(?P<item_id>\w+)/' + r'(?P<submited>\w+)?$', 'editMarker', name="edit-item"), url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-route/$', 'editRoute', name="editroute"), url(r'^(?P<area_name>[a-zA-Z0-9_-]+/)?edit-route/(?P<item_id>\w+)/' diff --git a/chimere/views.py b/chimere/views.py index 9f24767..d4f3bb3 100644 --- a/chimere/views.py +++ b/chimere/views.py @@ -209,6 +209,19 @@ def index(request, area_name=None, default_area=None, simple=False, context_instance=RequestContext(request)) +def edit(request, area_name="", item_id=None, submited=False): + """ + Edition page + """ + response_dct, redir = get_base_response(request, area_name) + if redir: + return redir + current_actions = actions(response_dct['area_name']) + redir = action_do_redirect('edit-no-page', current_actions) + # a redir is always send... or there is a problem + return redirect(redir) + + def get_edit_page(redirect_url, item_cls, item_form, multimediafile_formset=MultimediaFileFormSet, picturefile_formset=PictureFileFormSet): @@ -343,14 +356,15 @@ def action_do_redirect(action_name, available_actions): for subaction in subactions: if subaction.id == action_name: return - if is_edit and 'edit' not in redir: + if is_edit and 'edit' not in redir \ + and 'edit' in subaction.id: redir = subaction.url return redir -get_edit_marker = get_edit_page('chimere:edit', Marker, MarkerForm) +get_edit_marker = get_edit_page('chimere:editmarker', Marker, MarkerForm) -def edit(request, area_name="", item_id=None, submited=False): +def editMarker(request, area_name="", item_id=None, submited=False): """ Edition page """ @@ -363,7 +377,7 @@ def edit(request, area_name="", item_id=None, submited=False): # verify action is available current_actions = actions(response_dct['area_name']) - redir = action_do_redirect('edit-polygon', current_actions) + redir = action_do_redirect('edit-marker', current_actions) if redir: return redirect(redir) @@ -379,7 +393,7 @@ def edit(request, area_name="", item_id=None, submited=False): point_value = request.POST.get('point') response_dct.update({ 'actions': current_actions, - 'action_selected': ('contribute', 'edit'), + 'action_selected': ('contribute', 'edit-marker'), 'map_layer': settings.CHIMERE_DEFAULT_MAP_LAYER, 'form': form, 'formset_multi': formset_multi, @@ -485,7 +499,7 @@ def editRoute(request, area_name="", item_id=None, submited=False): # verify action is available current_actions = actions(response_dct['area_name']) - redir = action_do_redirect('edit-polygon', current_actions) + redir = action_do_redirect('edit-route', current_actions) if redir: return redirect(redir) |