diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2010-11-19 20:16:55 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2010-11-19 20:16:55 +0100 |
commit | 91e36a67f858d25fe6d7f38310a589a59c798f21 (patch) | |
tree | b3454ce352dcf813fd419251b082453715bac0bc /chimere/rss/views.py | |
parent | 38b44352960f40f0fdda87353b471a6b8f43d485 (diff) | |
download | Chimère-91e36a67f858d25fe6d7f38310a589a59c798f21.tar.bz2 Chimère-91e36a67f858d25fe6d7f38310a589a59c798f21.zip |
Cosmetic changes (refs #65)
Diffstat (limited to 'chimere/rss/views.py')
-rw-r--r-- | chimere/rss/views.py | 92 |
1 files changed, 55 insertions, 37 deletions
diff --git a/chimere/rss/views.py b/chimere/rss/views.py index 12269cd..dc42584 100644 --- a/chimere/rss/views.py +++ b/chimere/rss/views.py @@ -36,11 +36,11 @@ from chimere.main.actions import actions from chimere.main.models import Category, SubCategory, PropertyModel, Marker, \ Route, News, Area, Color -# Pierre CLARENC : 19/01/2010 : Add AreaWidget +# Pierre CLARENC : 19/01/2010 : Add AreaWidget from chimere.main.widgets import getMapJS, PointChooserWidget, \ RouteChooserWidget, URL_OSM_JS, URL_OSM_CSS, AreaWidget # Pierre CLARENC : 19/01/2010 : End -# Pierre CLARENC : 19/01/2010 : Add AreaAdminForm +# Pierre CLARENC : 19/01/2010 : Add AreaAdminForm from chimere.main.forms import MarkerForm, RouteForm, AreaForm, notifyStaff # Pierre CLARENC : 19/01/2010 : End @@ -50,96 +50,114 @@ def rss(request): ''' # If the form has been submited if request.method == "POST": - - # User has defined the kind of POI he is interested in : POI in a area (GET method is used for the link with RSS icon in the browser) + # User has defined the kind of POI he is interested in : POI in a area + # (GET method is used for the link with RSS icon in the browser) if 'rss_category' in request.POST: #User wants to follow all the new POI if request.POST['rss_category'] == 'global': feeds_link = '/' + settings.EXTRA_URL + 'rss/global/' return HttpResponseRedirect(feeds_link) # User wants to follow all the new POI by category or subcategory - elif request.POST['rss_category'] == 'poi': + elif request.POST['rss_category'] == 'poi': response_dct = {'actions':actions, 'action_selected':'rss', - 'media_path':settings.MEDIA_URL, - 'extra_url':settings.EXTRA_URL, - 'category_rss_feed':'category', - 'sub_categories':SubCategory.getAvailable(['M', 'B']) + 'media_path':settings.MEDIA_URL, + 'extra_url':settings.EXTRA_URL, + 'category_rss_feed':'category', + 'sub_categories':SubCategory.getAvailable(['M', 'B']) } return render_to_response('rss.html', response_dct) # User wants to follow all the new POI situated in a defined area - elif request.POST['rss_category'] == 'area': + elif request.POST['rss_category'] == 'area': # An unbound form - form = AreaForm() + form = AreaForm() response_dct = {'actions':actions, 'action_selected':'rss', 'media_path':settings.MEDIA_URL, 'extra_url':settings.EXTRA_URL, 'map_layer':settings.MAP_LAYER, 'extra_head':form.media, - 'form':form, - 'category_rss_feed':'area', + 'form':form, + 'category_rss_feed':'area', 'area_id':Area.getAvailable(), - 'area_widget':AreaWidget().render('area', None) + 'area_widget':AreaWidget().render('area', None) } return render_to_response('rss.html', response_dct) # Error when submitting the form else: + error = _("Error - Please choose a correct choice in the list") response_dct = {'actions':actions, 'action_selected':'rss', 'media_path':settings.MEDIA_URL, 'extra_url':settings.EXTRA_URL, - 'error_message':'Error - Please choose a correct choice in the list', + 'error_message':error, 'category_rss_feed':'category', - 'sub_categories':SubCategory.getAvailable(['M', 'B']) + 'sub_categories':SubCategory.getAvailable(['M', + 'B']) } return render_to_response('rss.html', response_dct) - # User has specified the category or subcategory he wants to follow => we redirect him towards the related rss feed - if 'subcategory' in request.POST and request.POST['subcategory'] != '': + # User has specified the category or subcategory he wants to follow => + # we redirect him towards the related rss feed + if 'subcategory' in request.POST and request.POST['subcategory'] != '': idCat = request.POST['subcategory'] if idCat.find("cat_") != -1 : - list_Cat = idCat.split('_') - feeds_link = '/' + settings.EXTRA_URL + 'rss/category/' + list_Cat[1] + list_Cat = idCat.split('_') + feeds_link = '/' + settings.EXTRA_URL + 'rss/category/' + feeds_link += list_Cat[1] return HttpResponseRedirect(feeds_link) else: - feeds_link = '/' + settings.EXTRA_URL + 'rss/subcategory/' + idCat - return HttpResponseRedirect(feeds_link) + feeds_link = '/' + settings.EXTRA_URL + 'rss/subcategory/' + \ + idCat + return HttpResponseRedirect(feeds_link) - # User has specified the ID of the area he wants to follow + # User has specified the ID of the area he wants to follow if 'id_area' in request.POST and request.POST['id_area'] != '': - feeds_link = '/' + settings.EXTRA_URL + 'rss/areaid/' + request.POST['id_area'] + feeds_link = '/' + settings.EXTRA_URL + 'rss/areaid/' \ + + request.POST['id_area'] return HttpResponseRedirect(feeds_link) - # User has specified the area he wants to follow => we redirect him towards the related rss feed (using upper left and lower right coordinates) - elif 'upper_left_lat' in request.POST and request.POST['upper_left_lat'] != '' and 'upper_left_lon' in request.POST and request.POST['upper_left_lon'] != '' and 'lower_right_lon' in request.POST and request.POST['lower_right_lon'] != '' and 'lower_right_lat' in request.POST and request.POST['lower_right_lat'] != '' : - feeds_link = '/' + settings.EXTRA_URL + 'rss/area/' + request.POST['upper_left_lat'] + ',' + request.POST['upper_left_lon'] + ',' + request.POST['lower_right_lat'] + ',' + request.POST['lower_right_lon'] + # User has specified the area he wants to follow => we redirect him + # towards the related rss feed (using upper left and lower right + # coordinates) + elif 'upper_left_lat' in request.POST and \ + request.POST['upper_left_lat'] != '' and \ + 'upper_left_lon' in request.POST and \ + request.POST['upper_left_lon'] != '' and \ + 'lower_right_lon' in request.POST and \ + request.POST['lower_right_lon'] != '' and \ + 'lower_right_lat' in request.POST and \ + request.POST['lower_right_lat'] != '' : + feeds_link = '/' + settings.EXTRA_URL + 'rss/area/' + \ +request.POST['upper_left_lat'] + ',' + request.POST['upper_left_lon'] + ',' + \ +request.POST['lower_right_lat'] + ',' + request.POST['lower_right_lon'] return HttpResponseRedirect(feeds_link) - - # GET method is used for linking with the RSS icon in the browser when user wants to choose a category to follow + + # GET method is used for linking with the RSS icon in the browser when user + # wants to choose a category to follow elif request.method == "GET" and 'rss_category' in request.GET: if request.GET['rss_category'] == 'global': feeds_link = '/' + settings.EXTRA_URL + 'rss/global/' return HttpResponseRedirect(feeds_link) if request.GET['rss_category'] == 'poi': response_dct = {'actions':actions, 'action_selected':'rss', - 'media_path':settings.MEDIA_URL, - 'extra_url':settings.EXTRA_URL, - 'category_rss_feed':'category', - 'sub_categories':SubCategory.getAvailable(['M', 'B']) + 'media_path':settings.MEDIA_URL, + 'extra_url':settings.EXTRA_URL, + 'category_rss_feed':'category', + 'sub_categories':SubCategory.getAvailable(['M', 'B']) } return render_to_response('rss.html', response_dct) if request.GET['rss_category'] == 'area': # An unbound form - form = AreaForm() + form = AreaForm() response_dct = {'actions':actions, 'action_selected':'rss', 'media_path':settings.MEDIA_URL, 'extra_url':settings.EXTRA_URL, 'map_layer':settings.MAP_LAYER, 'extra_head':form.media, - 'form':form, - 'category_rss_feed':'area', + 'form':form, + 'category_rss_feed':'area', 'area_id':Area.getAvailable(), - 'area_widget':AreaWidget().render('area', None) + 'area_widget':AreaWidget().render('area', None) } return render_to_response('rss.html', response_dct) |