remotes/origin/1203
parent
073150e432
commit
b89ccb3516
16 changed files with 145 additions and 253 deletions
@ -1,56 +1,18 @@ |
|||||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||||
from django.shortcuts import render_to_response |
|
||||||
from django.http import HttpResponseRedirect, HttpResponse |
|
||||||
from forms import LanguageForm, CurrencyForm, IataForm |
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): |
def language_add(request): |
||||||
""" |
""" |
||||||
Returns LanguageForm and post it on the server |
Return LanguageForm and post it on the server |
||||||
|
|
||||||
If form is posted redirects on the list of all countries |
|
||||||
""" |
""" |
||||||
if request.POST: |
return add_object(request, LanguageForm, 'directories_add.html', '/language/add') |
||||||
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 render_to_response('directories_add.html', args) |
|
||||||
|
|
||||||
@login_required |
|
||||||
def currency_add(request): |
def currency_add(request): |
||||||
""" |
""" |
||||||
Returns CurrencyForm and post it on the server |
Return CurrencyForm and post it on the server |
||||||
|
|
||||||
If form is posted redirects on the list of all countries |
|
||||||
""" |
""" |
||||||
if request.POST: |
return add_object(request, CurrencyForm, 'directories_add.html', '/currency/add') |
||||||
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) |
|
||||||
Loading…
Reference in new issue