remotes/origin/1203
parent
073150e432
commit
b89ccb3516
16 changed files with 145 additions and 253 deletions
@ -1,56 +1,18 @@ |
||||
# -*- coding: utf-8 -*- |
||||
from django.shortcuts import render_to_response |
||||
from django.http import HttpResponseRedirect, HttpResponse |
||||
from forms import LanguageForm, CurrencyForm, IataForm |
||||
from django.core.context_processors import csrf |
||||
#custom views |
||||
from functions.custom_views import add_object |
||||
|
||||
from models import Language, Currency |
||||
|
||||
from django.conf import settings |
||||
from django.contrib.auth.decorators import login_required |
||||
|
||||
@login_required |
||||
def language_add(request): |
||||
""" |
||||
Returns LanguageForm and post it on the server |
||||
|
||||
If form is posted redirects on the list of all countries |
||||
Return LanguageForm and post it on the server |
||||
""" |
||||
if request.POST: |
||||
form = LanguageForm(request.POST) |
||||
if form.is_valid(): |
||||
form.save() |
||||
return HttpResponseRedirect('/language/add') |
||||
|
||||
else: |
||||
form = LanguageForm() |
||||
|
||||
args = {} |
||||
args.update(csrf(request)) |
||||
args['languages'] = settings.LANGUAGES |
||||
args['form'] = form |
||||
return add_object(request, LanguageForm, 'directories_add.html', '/language/add') |
||||
|
||||
return render_to_response('directories_add.html', args) |
||||
|
||||
@login_required |
||||
def currency_add(request): |
||||
""" |
||||
Returns CurrencyForm and post it on the server |
||||
|
||||
If form is posted redirects on the list of all countries |
||||
Return CurrencyForm and post it on the server |
||||
""" |
||||
if request.POST: |
||||
form = CurrencyForm(request.POST) |
||||
if form.is_valid(): |
||||
form.save() |
||||
return HttpResponseRedirect('/currency/add') |
||||
|
||||
else: |
||||
form = CurrencyForm() |
||||
|
||||
args = {} |
||||
args.update(csrf(request)) |
||||
args['languages'] = settings.LANGUAGES |
||||
args['form'] = form |
||||
|
||||
return render_to_response('directories_add.html', args) |
||||
return add_object(request, CurrencyForm, 'directories_add.html', '/currency/add') |
||||
Loading…
Reference in new issue