Revision dcf55476 astakos/im/views.py
b/astakos/im/views.py | ||
---|---|---|
79 | 79 |
html = render_to_string(template, kwargs, context_instance=context_instance) |
80 | 80 |
return HttpResponse(html, status=status) |
81 | 81 |
|
82 |
def index(request, template_name='index.html', extra_context={}):
|
|
82 |
def index(request, login_template_name='login.html', profile_template_name='profile.html', extra_context={}):
|
|
83 | 83 |
""" |
84 |
Renders the index (login) page
|
|
84 |
If there is logged on user renders the profile page otherwise renders login page.
|
|
85 | 85 |
|
86 | 86 |
**Arguments** |
87 | 87 |
|
88 |
``template_name`` |
|
89 |
A custom template to use. This is optional; if not specified, |
|
90 |
this will default to ``index.html``. |
|
88 |
``login_template_name`` |
|
89 |
A custom login template to use. This is optional; if not specified, |
|
90 |
this will default to ``login.html``. |
|
91 |
|
|
92 |
``profile_template_name`` |
|
93 |
A custom profile template to use. This is optional; if not specified, |
|
94 |
this will default to ``login.html``. |
|
91 | 95 |
|
92 | 96 |
``extra_context`` |
93 | 97 |
An dictionary of variables to add to the template context. |
... | ... | |
97 | 101 |
index.html or ``template_name`` keyword argument. |
98 | 102 |
|
99 | 103 |
""" |
104 |
template_name = login_template_name |
|
105 |
formclass = 'LoginForm' |
|
106 |
kwargs = {} |
|
107 |
if request.user.is_authenticated(): |
|
108 |
template_name = profile_template_name |
|
109 |
formclass = 'ProfileForm' |
|
110 |
kwargs.update({'instance':request.user}) |
|
100 | 111 |
return render_response(template_name, |
101 |
form = LoginForm(),
|
|
112 |
form = globals()[formclass](**kwargs),
|
|
102 | 113 |
context_instance = get_context(request, extra_context)) |
103 | 114 |
|
104 | 115 |
def _generate_invitation_code(): |
Also available in: Unified diff