Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
dcf55476
Commit
dcf55476
authored
Jan 25, 2012
by
Sofia Papagiannaki
Browse files
change index view: if there is logged in user render profile page
Refs: #1918
parent
213ea9a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
astakos/im/templates/
index
.html
→
astakos/im/templates/
login
.html
View file @
dcf55476
File moved
astakos/im/views.py
View file @
dcf55476
...
...
@@ -79,15 +79,19 @@ def render_response(template, tab=None, status=200, context_instance=None, **kwa
html
=
render_to_string
(
template
,
kwargs
,
context_instance
=
context_instance
)
return
HttpResponse
(
html
,
status
=
status
)
def
index
(
request
,
template_name
=
'
index
.html'
,
extra_context
=
{}):
def
index
(
request
,
login_
template_name
=
'
login.html'
,
profile_template_name
=
'profile
.html'
,
extra_context
=
{}):
"""
Renders the index (
login
)
page
If there is logged on user renders the profile page otherwise renders
login page
.
**Arguments**
``template_name``
A custom template to use. This is optional; if not specified,
this will default to ``index.html``.
``login_template_name``
A custom login template to use. This is optional; if not specified,
this will default to ``login.html``.
``profile_template_name``
A custom profile template to use. This is optional; if not specified,
this will default to ``login.html``.
``extra_context``
An dictionary of variables to add to the template context.
...
...
@@ -97,8 +101,15 @@ def index(request, template_name='index.html', extra_context={}):
index.html or ``template_name`` keyword argument.
"""
template_name
=
login_template_name
formclass
=
'LoginForm'
kwargs
=
{}
if
request
.
user
.
is_authenticated
():
template_name
=
profile_template_name
formclass
=
'ProfileForm'
kwargs
.
update
({
'instance'
:
request
.
user
})
return
render_response
(
template_name
,
form
=
LoginForm
(
),
form
=
globals
()[
formclass
](
**
kwargs
),
context_instance
=
get_context
(
request
,
extra_context
))
def
_generate_invitation_code
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment