Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Sith
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AE
Sith
Commits
89849032
Commit
89849032
authored
Nov 19, 2015
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic user profile
parent
c8680ec8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
3 deletions
+59
-3
core/models.py
core/models.py
+9
-0
core/templates/core/index.html
core/templates/core/index.html
+7
-1
core/templates/core/user.html
core/templates/core/user.html
+28
-0
core/urls.py
core/urls.py
+3
-0
core/views.py
core/views.py
+12
-2
No files found.
core/models.py
View file @
89849032
...
...
@@ -74,6 +74,15 @@ class User(AbstractBaseUser, PermissionsMixin):
"Returns the short name for the user."
return
self
.
first_name
def
get_display_name
(
self
):
"""
Returns the display name of the user.
A nickname if possible, otherwise, the full name
"""
if
self
.
nick_name
!=
""
:
return
self
.
nick_name
return
self
.
get_full_name
()
def
email_user
(
self
,
subject
,
message
,
from_email
=
None
,
**
kwargs
):
"""
Sends an email to this User.
...
...
core/templates/core/index.html
View file @
89849032
{% extends "sith/base.html" %}
{% extends "core/base.html" %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
Hello, world. You're at the core index.
{% endblock %}
core/templates/core/user.html
0 → 100644
View file @
89849032
{% extends "core/base.html" %}
{% block title %}
{% if profile %}
{{ profile.get_display_name }}'s profile
{% endif %}
{% if user_list %}
User list
{% endif %}
{% endblock %}
{% block content %}
{% if profile %}
<h3>
User Profile
</h3>
<p><a
href=
"{% url 'core:user_list' %}"
>
Back to list
</a></p>
<p>
You're seeing the profile of
<strong>
{{ profile.get_display_name }}
</strong></p>
{% endif %}
{% if user_list %}
<h3>
User list
</h3>
<ul>
{% for u in user_list %}
<li><a
href=
"{% url 'core:user_profile' u.id %}"
>
{{ u.get_display_name }}
</a></li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}
core/urls.py
View file @
89849032
...
...
@@ -7,5 +7,8 @@ urlpatterns = [
url
(
r
'^login$'
,
views
.
login
,
name
=
'login'
),
url
(
r
'^logout$'
,
views
.
logout
,
name
=
'logout'
),
url
(
r
'^register$'
,
views
.
register
,
name
=
'register'
),
url
(
r
'^user/$'
,
views
.
user
,
name
=
'user_list'
),
url
(
r
'^user/(?P<user_id>[0-9]+)/$'
,
views
.
user
,
name
=
'user_profile'
),
url
(
r
'^user/(?P<user_id>[0-9]+)/edit$'
,
views
.
user_edit
,
name
=
'user_edit'
),
]
core/views.py
View file @
89849032
from
django.shortcuts
import
render
,
redirect
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
django.http
import
HttpResponse
from
django.contrib.auth
import
logout
as
auth_logout
...
...
@@ -10,7 +10,7 @@ import logging
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
def
index
(
request
):
return
HttpResponse
(
"Hello, world. You're at the core index."
)
return
render
(
request
,
"core/index.html"
,
{
'title'
:
'Bienvenue!'
}
)
def
register
(
request
):
if
request
.
method
==
'POST'
:
...
...
@@ -39,3 +39,13 @@ def login(request):
def
logout
(
request
):
auth_logout
(
request
)
return
redirect
(
'core:index'
)
def
user
(
request
,
user_id
=
None
):
if
user_id
==
None
:
return
render
(
request
,
"core/user.html"
,
{
'user_list'
:
User
.
objects
.
all
})
user
=
get_object_or_404
(
User
,
pk
=
user_id
)
return
render
(
request
,
"core/user.html"
,
{
'profile'
:
user
})
def
user_edit
(
request
,
user_id
):
pass
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