diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-08-27 19:53:17 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2012-08-27 19:53:17 +0200 |
commit | 427a05d328fccc99a9339dbc6c933281eaaaa3b9 (patch) | |
tree | b0c7cbf440ff5b29e71074a35e542b1aaffa8dc4 /views.py | |
parent | cfd0b613480a841bb82c67f0354b44b8d1f5063c (diff) | |
download | Chimère - projet Saclay-427a05d328fccc99a9339dbc6c933281eaaaa3b9.tar.bz2 Chimère - projet Saclay-427a05d328fccc99a9339dbc6c933281eaaaa3b9.zip |
Work on form panel
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/views.py b/views.py new file mode 100644 index 0000000..4bc5bc6 --- /dev/null +++ b/views.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2012 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# See the file COPYING for details. + +from django.conf import settings +from django.shortcuts import render_to_response +from django.template import RequestContext + +from forms import MarkerForm + +from chimere.actions import actions +from chimere.models import Marker, PropertyModel +from chimere.views import get_edit_page + +get_edit_marker = get_edit_page('edit', Marker, MarkerForm) + +def edit(request, area_name="", item_id=None, submited=False): + """ + Edition page + """ + response, values, sub_categories = get_edit_marker(request, area_name, + item_id, ['M', 'B']) + if response: + return response + item_id, init_item, response_dct, form, formset_multi, formset_picture = \ + values + # get the "manualy" declared_fields. Ie: properties + declared_fields = form.declared_fields.keys() + declared_fields = PropertyModel.objects.filter(available=True).all() + filtered_properties = PropertyModel.objects.filter(available=True, + subcategories__id__isnull=False).all() + response_dct.update({ + 'actions':actions, + 'action_selected':('contribute', 'edit'), + 'map_layer':settings.CHIMERE_DEFAULT_MAP_LAYER, + 'form':form, + 'formset_multi':formset_multi, + 'formset_picture':formset_picture, + 'dated':settings.CHIMERE_DAYS_BEFORE_EVENT, + 'extra_head':form.media, + 'marker_id':item_id, + 'sub_categories':sub_categories, + 'point_widget':'', + 'properties':declared_fields, + 'filtered_properties':filtered_properties, + 'submited':submited + }) + # manualy populate the custom widget + if 'subcategory' in form.data and form.data['subcategory']: + response_dct['current_category'] = int(form.data['subcategory']) + return render_to_response('chimere/edit.html', response_dct, + context_instance=RequestContext(request)) |