Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
330c1d38
authored
Jun 03, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: basic user profile
parent
1519d326
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
144 additions
and
2 deletions
+144
-2
circle/dashboard/static/dashboard/dashboard.css
+10
-0
circle/dashboard/templates/base.html
+1
-1
circle/dashboard/templates/dashboard/profile.html
+96
-0
circle/dashboard/urls.py
+3
-1
circle/dashboard/views.py
+34
-0
No files found.
circle/dashboard/static/dashboard/dashboard.css
View file @
330c1d38
...
...
@@ -654,3 +654,13 @@ textarea[name="list-new-namelist"] {
80
%
{
-webkit-transform
:
scale
(
1
);
}
100
%
{
-webkit-transform
:
scale
(
1
);
}
}
.dashboard-profile-vm-list
,
.dashboard-profile-group-list
{
list-style
:
none
;
padding-left
:
28px
;
}
.dashboard-profile-vm-list
a
,
.dashboard-profile-vm-list
a
:hover
{
text-decoration
:
none
;
color
:
#555
;
}
circle/dashboard/templates/base.html
View file @
330c1d38
...
...
@@ -49,7 +49,7 @@
</ul>
{% if user.is_authenticated %}
<a
class=
"navbar-brand pull-right"
href=
"{% url "
logout
"
%}?
next=
{%
url
"
login
"
%}"
style=
"color: white; font-size: 10px;"
><i
class=
"icon-signout icon-sign-out"
></i>
{% trans "Log out" %}
</a>
<a
class=
"navbar-brand pull-right"
href=
"{% url "
dashboard
.
views
.
profile
"
%}"
title=
"{% trans "
User
profile
"
%}"
style=
"color: white; font-size: 10px;"
><i
class=
"icon-user "
></i>
{{user}}
</a>
<a
class=
"navbar-brand pull-right"
href=
"{% url "
dashboard
.
views
.
profile
"
pk=
user.pk
%}"
title=
"{% trans "
User
profile
"
%}"
style=
"color: white; font-size: 10px;"
><i
class=
"icon-user "
></i>
{{user}}
</a>
{% if user.is_superuser %}
<a
class=
"navbar-brand pull-right"
href=
"/network/"
style=
"color: white; font-size: 10px;"
><i
class=
"icon-globe"
></i>
{% trans "Network" %}
</a>
<a
class=
"navbar-brand pull-right"
href=
"/admin/"
style=
"color: white; font-size: 10px;"
><i
class=
"icon-cogs"
></i>
{% trans "Admin" %}
</a>
...
...
circle/dashboard/templates/dashboard/profile.html
0 → 100644
View file @
330c1d38
{% extends "dashboard/base.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block title-page %}{{ profile.username}} | {% trans "Profile" %}{% endblock %}
{% block content %}
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<a
class=
"pull-right btn btn-default btn-xs"
href=
"{% url "
dashboard
.
index
"
%}"
>
{% trans "Back" %}
</a>
<h3
class=
"no-margin"
>
<i
class=
"icon-user"
></i>
{% include "dashboard/_display-name.html" with user=profile show_org=True %}
</h3>
</div>
<div
class=
"panel-body"
>
<div>
<div
class=
""
style=
"float: left"
>
<img
src=
"{{ avatar_url }}?s=200"
class=
"img-rounded"
/>
</div>
<div
class=
""
style=
"padding-left: 215px;"
>
<p>
Username: {{ profile.username }}
</p>
<p>
Organisation ID: {{ profile.profile.org_id|default:"-" }}
</p>
<p>
First name: {{ profile.first_name|default:"-" }}
</p>
<p>
Last name: {{ profile.last_name|default:"-" }}
</p>
<p>
Email address: {{ profile.email }}
</p>
<p>
Use email address as Gravatar profile image:
<input
type=
"checkbox"
/>
<a
href=
"https://gravatar.com"
>
What's Gravatar?
</a>
</p>
</div>
<div
class=
"clearfix"
></div>
</div>
<hr
/>
<h4>
<i
class=
"icon-group"
></i>
Groups
</h4>
<ul
class=
"dashboard-profile-group-list"
>
{% for g in groups %}
<li>
{{ g.name }}
</li>
{% empty %}
{% trans "This user is not in any group." %}
{% endfor %}
</ul>
<hr
/>
<h4>
<i
class=
"icon-desktop"
></i>
Virtual machines owned by the user ({{ instances_owned|length }})
</h4>
<ul
class=
"dashboard-profile-vm-list"
>
{% for i in instances_owned %}
<li>
<a
href=
"{{ i.get_absolute_url }}"
>
<i
class=
"icon-li {{ i.get_status_icon }}"
></i>
{{ i }}
</a>
</li>
{% empty %}
<li>
{% trans "This user have no virtual machines." %}
</li>
{% endfor %}
</ul>
<hr
/>
<h4>
<i
class=
"icon-desktop"
></i>
Virtual machines with access ({{ instances_with_access|length }})
</h4>
<ul
class=
"dashboard-profile-vm-list"
>
{% for i in instances_with_access %}
<li>
<a
href=
"{{ i.get_absolute_url }}"
>
<i
class=
"icon-li {{ i.get_status_icon }}"
></i>
{{ i }}
</a>
</li>
{% empty %}
<li>
{% trans "This user have no access to any virtual machine." %}
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
{% endblock %}
circle/dashboard/urls.py
View file @
330c1d38
...
...
@@ -34,6 +34,7 @@ from .views import (
GroupCreate
,
TemplateChoose
,
UserCreationView
,
ProfileView
,
)
urlpatterns
=
patterns
(
...
...
@@ -132,8 +133,9 @@ urlpatterns = patterns(
url
(
r'^interface/(?P<pk>\d+)/delete/$'
,
InterfaceDeleteView
.
as_view
(),
name
=
"dashboard.views.interface-delete"
),
url
(
r'^profile/
$'
,
MyPreferences
View
.
as_view
(),
url
(
r'^profile/
(?P<pk>\d+)$'
,
Profile
View
.
as_view
(),
name
=
"dashboard.views.profile"
),
url
(
r'^group/(?P<group_pk>\d+)/remove/acl/user/(?P<member_pk>\d+)/$'
,
GroupRemoveAclUserView
.
as_view
(),
name
=
"dashboard.views.remove-acluser"
),
...
...
circle/dashboard/views.py
View file @
330c1d38
...
...
@@ -21,6 +21,7 @@ from os import getenv
import
json
import
logging
import
re
from
hashlib
import
md5
import
requests
from
django.conf
import
settings
...
...
@@ -2649,3 +2650,36 @@ class InterfaceDeleteView(DeleteView):
if
redirect
:
return
redirect
self
.
object
.
instance
.
get_absolute_url
()
class
ProfileView
(
DetailView
):
template_name
=
"dashboard/profile.html"
model
=
User
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
ProfileView
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'profile'
]
=
self
.
get_object
()
context
[
'avatar_url'
]
=
self
.
get_avatar_url
()
context
[
'instances_owned'
]
=
Instance
.
get_objects_with_level
(
"owner"
,
self
.
get_object
(),
disregard_superuser
=
True
)
.
filter
(
destroyed_at
=
None
)
context
[
'instances_with_access'
]
=
[
inst
for
inst
in
Instance
.
get_objects_with_level
(
"user"
,
self
.
get_object
(),
disregard_superuser
=
True
)
.
filter
(
destroyed_at
=
None
)
if
inst
not
in
context
[
'instances_owned'
]
]
group_profiles
=
GroupProfile
.
get_objects_with_level
(
"operator"
,
self
.
request
.
user
)
groups
=
Group
.
objects
.
filter
(
groupprofile__in
=
group_profiles
)
context
[
'groups'
]
=
[
g
for
g
in
self
.
get_object
()
.
groups
.
all
()
if
g
in
groups
]
return
context
def
get_avatar_url
(
self
):
user
=
self
.
get_object
()
gravatar_hash
=
md5
(
user
.
email
)
.
hexdigest
()
return
"https://gravatar.com/avatar/
%
s"
%
gravatar_hash
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