-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathviews.py
executable file
·24 lines (22 loc) · 1.05 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.template.context import Context, RequestContext
from django.shortcuts import render_to_response
from django.conf import settings
def home(request):
if request.user.is_authenticated():
if request.user.is_superuser:
return HttpResponseRedirect(settings.SITE_URL + 'admin/')
elif request.user.get_profile().is_core:
return HttpResponseRedirect(settings.SITE_URL + 'core/')
else:
return render_to_response('home.html',locals(),context_instance = RequestContext(request))
else:
return render_to_response('home.html',locals(),context_instance = RequestContext(request))
def method_splitter(request, *args, **kwargs):
get_view = kwargs.pop('GET', None)
post_view = kwargs.pop('POST', None)
if request.method == 'GET' and get_view is not None:
return get_view(request, *args, **kwargs)
elif request.method == 'POST' and post_view is not None:
return post_view(request, *args, **kwargs)
raise Http404