Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
e75da927
Commit
e75da927
authored
May 11, 2016
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve group views
parent
ac37d332
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
15 deletions
+42
-15
core/migrations/0002_group_description.py
core/migrations/0002_group_description.py
+20
-0
core/models.py
core/models.py
+4
-1
core/templates/core/group_list.jinja
core/templates/core/group_list.jinja
+3
-1
core/urls.py
core/urls.py
+2
-0
core/views/forms.py
core/views/forms.py
+0
-11
core/views/group.py
core/views/group.py
+13
-2
No files found.
core/migrations/0002_group_description.py
0 → 100644
View file @
e75da927
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'core'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'group'
,
name
=
'description'
,
field
=
models
.
CharField
(
max_length
=
60
,
verbose_name
=
'description'
,
default
=
'guy'
),
preserve_default
=
False
,
),
]
core/models.py
View file @
e75da927
...
...
@@ -24,11 +24,12 @@ class Group(AuthGroup):
default
=
False
,
help_text
=
_
(
'Whether a group is a meta group or not'
),
)
description
=
models
.
CharField
(
_
(
'description'
),
max_length
=
60
)
def
get_absolute_url
(
self
):
"""
This is needed for black magic powered UpdateView's children
"""
return
reverse
(
'core:group_
edit'
,
kwargs
=
{
'group_id'
:
self
.
pk
}
)
return
reverse
(
'core:group_
list'
)
class
MetaGroup
(
Group
):
objects
=
MetaGroupManager
()
...
...
@@ -148,6 +149,8 @@ class User(AbstractBaseUser, PermissionsMixin):
return
False
else
:
return
False
if
group_name
==
settings
.
SITH_GROUPS
[
'root'
][
'name'
]
and
self
.
is_superuser
:
return
True
return
self
.
groups
.
filter
(
name
=
group_name
).
exists
()
def
get_profile
(
self
):
...
...
core/templates/core/group_list.jinja
View file @
e75da927
...
...
@@ -6,9 +6,11 @@ Group list
{%
block
content
%}
<h3>
Group list
</h3>
<p><a
href=
"
{{
url
(
'core:group_new'
)
}}
"
>
New group
</a></p>
<ul>
{%
for
g
in
realgroup_list
%}
<li><a
href=
"
{{
url
(
'core:group_edit'
,
group_id
=
g.id
)
}}
"
>
{{
g.name
}}
</a></li>
<li><a
href=
"
{{
url
(
'core:group_edit'
,
group_id
=
g.id
)
}}
"
>
{{
g.name
}}
</a>
-
{{
g.description
}}
-
<a
href=
"
{{
url
(
'core:group_delete'
,
group_id
=
g.id
)
}}
"
>
Delete
</a></li>
{%
endfor
%}
</ul>
{%
endblock
%}
...
...
core/urls.py
View file @
e75da927
...
...
@@ -18,7 +18,9 @@ urlpatterns = [
# Group handling
url
(
r
'^group/$'
,
GroupListView
.
as_view
(),
name
=
'group_list'
),
url
(
r
'^group/new$'
,
GroupCreateView
.
as_view
(),
name
=
'group_new'
),
url
(
r
'^group/(?P<group_id>[0-9]+)/$'
,
GroupEditView
.
as_view
(),
name
=
'group_edit'
),
url
(
r
'^group/(?P<group_id>[0-9]+)/delete$'
,
GroupDeleteView
.
as_view
(),
name
=
'group_delete'
),
# User views
url
(
r
'^user/$'
,
UserListView
.
as_view
(),
name
=
'user_list'
),
...
...
core/views/forms.py
View file @
e75da927
...
...
@@ -60,14 +60,3 @@ class PagePropForm(forms.ModelForm):
self
.
fields
[
'edit_groups'
].
required
=
False
self
.
fields
[
'view_groups'
].
required
=
False
class
GroupEditForm
(
forms
.
ModelForm
):
error_css_class
=
'error'
required_css_class
=
'required'
class
Meta
:
model
=
RealGroup
fields
=
[
'name'
,
'permissions'
,]
widgets
=
{
'permissions'
:
CheckboxSelectMultiple
,
}
core/views/group.py
View file @
e75da927
from
django.views.generic.edit
import
UpdateView
from
django.views.generic.edit
import
UpdateView
,
CreateView
,
DeleteView
from
django.views.generic
import
ListView
from
django.core.urlresolvers
import
reverse_lazy
from
core.models
import
RealGroup
from
core.views.forms
import
GroupEditForm
...
...
@@ -16,5 +17,15 @@ class GroupEditView(CanEditMixin, UpdateView):
model
=
RealGroup
pk_url_kwarg
=
"group_id"
template_name
=
"core/group_edit.jinja"
f
orm_class
=
GroupEditForm
f
ields
=
[
'name'
,
'description'
]
class
GroupCreateView
(
CanEditMixin
,
CreateView
):
model
=
RealGroup
template_name
=
"core/group_edit.jinja"
fields
=
[
'name'
,
'description'
]
class
GroupDeleteView
(
CanEditMixin
,
DeleteView
):
model
=
RealGroup
pk_url_kwarg
=
"group_id"
template_name
=
"core/delete_confirm.jinja"
success_url
=
reverse_lazy
(
'core:group_list'
)
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