Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
5bcc94f9
Commit
5bcc94f9
authored
Mar 29, 2016
by
Skia
Browse files
Improve counters views
parent
21f13930
Changes
10
Hide whitespace changes
Inline
Side-by-side
core/management/commands/populate.py
View file @
5bcc94f9
...
@@ -6,7 +6,7 @@ from django.conf import settings
...
@@ -6,7 +6,7 @@ from django.conf import settings
from
core.models
import
Group
,
User
,
Page
,
PageRev
from
core.models
import
Group
,
User
,
Page
,
PageRev
from
accounting.models
import
Customer
,
GeneralJournal
,
ProductType
,
Product
from
accounting.models
import
Customer
,
GeneralJournal
,
ProductType
,
Product
from
club.models
import
Club
from
club.models
import
Club
,
Membership
from
subscription.models
import
Subscription
,
Subscriber
from
subscription.models
import
Subscription
,
Subscriber
class
Command
(
BaseCommand
):
class
Command
(
BaseCommand
):
...
@@ -48,7 +48,6 @@ Welcome to the wiki page!
...
@@ -48,7 +48,6 @@ Welcome to the wiki page!
s
.
set_password
(
"plop"
)
s
.
set_password
(
"plop"
)
s
.
save
()
s
.
save
()
s
.
view_groups
=
[
settings
.
AE_GROUPS
[
'members'
][
'id'
]]
s
.
view_groups
=
[
settings
.
AE_GROUPS
[
'members'
][
'id'
]]
s
.
groups
=
[
settings
.
AE_GROUPS
[
'board'
][
'id'
]]
s
.
save
()
s
.
save
()
# Adding user Guy
# Adding user Guy
u
=
User
(
username
=
'guy'
,
last_name
=
"Carlier"
,
first_name
=
"Guy"
,
u
=
User
(
username
=
'guy'
,
last_name
=
"Carlier"
,
first_name
=
"Guy"
,
...
@@ -98,6 +97,7 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
...
@@ -98,6 +97,7 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
address
=
"Woenzel"
,
parent
=
guyut
).
save
()
address
=
"Woenzel"
,
parent
=
guyut
).
save
()
Club
(
name
=
"BdF"
,
unix_name
=
"bdf"
,
Club
(
name
=
"BdF"
,
unix_name
=
"bdf"
,
address
=
"Guyéuéyuéyuyé"
).
save
()
address
=
"Guyéuéyuéyuyé"
).
save
()
Membership
(
user
=
s
,
club
=
ae
,
role
=
3
,
description
=
""
).
save
()
# Accounting test values:
# Accounting test values:
Customer
(
user
=
s
,
account_id
=
"6568j"
).
save
()
Customer
(
user
=
s
,
account_id
=
"6568j"
).
save
()
...
@@ -105,5 +105,11 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
...
@@ -105,5 +105,11 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
p
.
save
()
p
.
save
()
Product
(
name
=
"Barbar"
,
code
=
"BARB"
,
product_type
=
p
,
purchase_price
=
"1.50"
,
selling_price
=
"1.7"
,
Product
(
name
=
"Barbar"
,
code
=
"BARB"
,
product_type
=
p
,
purchase_price
=
"1.50"
,
selling_price
=
"1.7"
,
special_selling_price
=
"1.6"
).
save
()
special_selling_price
=
"1.6"
).
save
()
Product
(
name
=
"Chimay"
,
code
=
"CBLE"
,
product_type
=
p
,
purchase_price
=
"1.50"
,
selling_price
=
"1.7"
,
special_selling_price
=
"1.6"
).
save
()
Product
(
name
=
"Corsendonk"
,
code
=
"CORS"
,
product_type
=
p
,
purchase_price
=
"1.50"
,
selling_price
=
"1.7"
,
special_selling_price
=
"1.6"
).
save
()
Product
(
name
=
"Carolus"
,
code
=
"CARO"
,
product_type
=
p
,
purchase_price
=
"1.50"
,
selling_price
=
"1.7"
,
special_selling_price
=
"1.6"
).
save
()
GeneralJournal
(
start_date
=
"2015-06-12"
,
name
=
"A15"
).
save
()
GeneralJournal
(
start_date
=
"2015-06-12"
,
name
=
"A15"
).
save
()
core/templates/core/delete_confirm.jinja
0 → 100644
View file @
5bcc94f9
{%
extends
"core/base.jinja"
%}
{%
block
content
%}
<h2>
Delete confirmation
</h2>
<form
action=
""
method=
"post"
>
{%
csrf_token
%}
<p>
Are you sure you want to delete "
{{
object
}}
"?
</p>
<input
type=
"submit"
value=
"Confirm"
/>
<input
type=
"submit"
name=
"cancel"
value=
"Cancel"
/>
</form>
{%
endblock
%}
core/templates/core/user_tools.jinja
View file @
5bcc94f9
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
{%
endif
%}
{%
endif
%}
{%
if
user.is_in_group
(
settings.AE_GROUPS
[
'root'
][
'name'
])
or
user.is_in_group
(
settings.AE_GROUPS
[
'board'
][
'name'
])
%}
{%
if
user.is_in_group
(
settings.AE_GROUPS
[
'root'
][
'name'
])
or
user.is_in_group
(
settings.AE_GROUPS
[
'board'
][
'name'
])
%}
<li><a
href=
"
{{
url
(
'subscription:subscription'
)
}}
"
>
Subscriptions
</a></li>
<li><a
href=
"
{{
url
(
'subscription:subscription'
)
}}
"
>
Subscriptions
</a></li>
<li><a
href=
"
{{
url
(
'counter:list'
)
}}
"
>
Counters management
</a></li>
<li><a
href=
"
{{
url
(
'counter:
admin_
list'
)
}}
"
>
Counters management
</a></li>
{%
endif
%}
{%
endif
%}
</ul>
</ul>
...
...
counter/migrations/0002_counter_type.py
0 → 100644
View file @
5bcc94f9
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'counter'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'counter'
,
name
=
'type'
,
field
=
models
.
CharField
(
max_length
=
255
,
default
=
'BAR'
,
verbose_name
=
'subscription type'
,
choices
=
[(
'BAR'
,
'Bar'
),
(
'OFFICE'
,
'Office'
)]),
preserve_default
=
False
,
),
]
counter/models.py
View file @
5bcc94f9
from
django.db
import
models
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
club.models
import
Club
from
club.models
import
Club
from
accounting.models
import
Product
from
accounting.models
import
Product
...
@@ -10,6 +11,9 @@ class Counter(models.Model):
...
@@ -10,6 +11,9 @@ class Counter(models.Model):
name
=
models
.
CharField
(
_
(
'name'
),
max_length
=
30
)
name
=
models
.
CharField
(
_
(
'name'
),
max_length
=
30
)
club
=
models
.
ForeignKey
(
Club
,
related_name
=
"counters"
)
club
=
models
.
ForeignKey
(
Club
,
related_name
=
"counters"
)
products
=
models
.
ManyToManyField
(
Product
,
related_name
=
"counters"
,
blank
=
True
)
products
=
models
.
ManyToManyField
(
Product
,
related_name
=
"counters"
,
blank
=
True
)
type
=
models
.
CharField
(
_
(
'subscription type'
),
max_length
=
255
,
choices
=
[(
'BAR'
,
_
(
'Bar'
)),
(
'OFFICE'
,
_
(
'Office'
))])
# TODO: add _ to translate
edit_groups
=
models
.
ManyToManyField
(
Group
,
related_name
=
"editable_counters"
,
blank
=
True
)
edit_groups
=
models
.
ManyToManyField
(
Group
,
related_name
=
"editable_counters"
,
blank
=
True
)
view_groups
=
models
.
ManyToManyField
(
Group
,
related_name
=
"viewable_counters"
,
blank
=
True
)
view_groups
=
models
.
ManyToManyField
(
Group
,
related_name
=
"viewable_counters"
,
blank
=
True
)
...
@@ -20,3 +24,9 @@ class Counter(models.Model):
...
@@ -20,3 +24,9 @@ class Counter(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
name
return
self
.
name
def
get_absolute_url
(
self
):
return
reverse
(
'counter:details'
,
kwargs
=
{
'counter_id'
:
self
.
id
})
def
can_be_viewed_by
(
self
,
user
):
return
user
.
is_in_group
(
settings
.
AE_GROUPS
[
'board'
][
'name'
])
counter/templates/counter/counter_edit.jinja
0 → 100644
View file @
5bcc94f9
{%
extends
"core/base.jinja"
%}
{%
block
content
%}
<h2>
Edit counter
</h2>
<form
action=
""
method=
"post"
>
{%
csrf_token
%}
{{
form.as_p
()
}}
<p><input
type=
"submit"
value=
"Save!"
/></p>
</form>
{%
endblock
%}
counter/templates/counter/counter_list.jinja
View file @
5bcc94f9
{%
extends
"core/base.jinja"
%}
{%
extends
"core/base.jinja"
%}
{%
block
title
%}
{%
block
title
%}
Counter list
Counter
admin
list
{%
endblock
%}
{%
endblock
%}
{%
block
content
%}
{%
block
content
%}
<p><a
href=
"
{{
url
(
'counter:new'
)
}}
"
>
New counter
</a></p>
{%
if
counter_list
%}
{%
if
counter_list
%}
<h3>
Counter list
</h3>
<h3>
Counter
admin
list
</h3>
<ul>
<ul>
{%
for
c
in
counter_list
%}
{%
for
c
in
counter_list
%}
<li><a
href=
"
{{
url
(
'counter:details'
,
counter_id
=
c.id
)
}}
"
>
{{
c
}}
</a></li>
<li><a
href=
"
{{
url
(
'counter:details'
,
counter_id
=
c.id
)
}}
"
>
{{
c
}}
</a>
-
<a
href=
"
{{
url
(
'counter:admin'
,
counter_id
=
c.id
)
}}
"
>
Edit
</a>
-
<a
href=
"
{{
url
(
'counter:delete'
,
counter_id
=
c.id
)
}}
"
>
Delete
</a></li>
{%
endfor
%}
{%
endfor
%}
</ul>
</ul>
{%
else
%}
{%
else
%}
...
...
counter/urls.py
View file @
5bcc94f9
...
@@ -3,8 +3,11 @@ from django.conf.urls import url, include
...
@@ -3,8 +3,11 @@ from django.conf.urls import url, include
from
counter.views
import
*
from
counter.views
import
*
urlpatterns
=
[
urlpatterns
=
[
url
(
r
'^$'
,
CounterListView
.
as_view
(),
name
=
'list'
),
url
(
r
'^(?P<counter_id>[0-9]+)$'
,
CounterDetail
.
as_view
(),
name
=
'details'
),
url
(
r
'^(?P<counter_id>[0-9]+)$'
,
CounterDetail
.
as_view
(),
name
=
'details'
),
url
(
r
'^admin/(?P<counter_id>[0-9]+)$'
,
CounterEditView
.
as_view
(),
name
=
'admin'
),
url
(
r
'^admin$'
,
CounterListView
.
as_view
(),
name
=
'admin_list'
),
url
(
r
'^admin/new$'
,
CounterCreateView
.
as_view
(),
name
=
'new'
),
url
(
r
'^admin/delete/(?P<counter_id>[0-9]+)$'
,
CounterDeleteView
.
as_view
(),
name
=
'delete'
),
]
]
counter/views.py
View file @
5bcc94f9
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views.generic
import
ListView
,
DetailView
from
django.views.generic
import
ListView
,
DetailView
from
django.views.generic.edit
import
UpdateView
,
CreateView
,
DeleteView
from
django.forms.models
import
modelform_factory
from
django.forms
import
CheckboxSelectMultiple
from
django.core.urlresolvers
import
reverse_lazy
from
core.views
import
CanViewMixin
,
CanEditMixin
,
CanEditPropMixin
from
core.views
import
CanViewMixin
,
CanEditMixin
,
CanEditPropMixin
from
counter.models
import
Counter
from
counter.models
import
Counter
...
@@ -13,3 +17,31 @@ class CounterDetail(CanViewMixin, DetailView):
...
@@ -13,3 +17,31 @@ class CounterDetail(CanViewMixin, DetailView):
model
=
Counter
model
=
Counter
template_name
=
'counter/counter_detail.jinja'
template_name
=
'counter/counter_detail.jinja'
pk_url_kwarg
=
"counter_id"
pk_url_kwarg
=
"counter_id"
class
CounterEditView
(
CanEditMixin
,
UpdateView
):
"""
Edit a Counter's main informations (for the counter's members)
"""
model
=
Counter
form_class
=
modelform_factory
(
Counter
,
fields
=
[
'name'
,
'club'
,
'type'
,
'products'
],
widgets
=
{
'products'
:
CheckboxSelectMultiple
})
pk_url_kwarg
=
"counter_id"
template_name
=
'counter/counter_edit.jinja'
class
CounterCreateView
(
CanEditMixin
,
CreateView
):
"""
Edit a Counter's main informations (for the counter's members)
"""
model
=
Counter
form_class
=
modelform_factory
(
Counter
,
fields
=
[
'name'
,
'club'
,
'type'
,
'products'
],
widgets
=
{
'products'
:
CheckboxSelectMultiple
})
template_name
=
'counter/counter_edit.jinja'
class
CounterDeleteView
(
CanEditMixin
,
DeleteView
):
"""
Edit a Counter's main informations (for the counter's members)
"""
model
=
Counter
pk_url_kwarg
=
"counter_id"
template_name
=
'core/delete_confirm.jinja'
success_url
=
reverse_lazy
(
'counter:admin_list'
)
sith/settings.py
View file @
5bcc94f9
...
@@ -191,11 +191,11 @@ AE_GROUPS = {
...
@@ -191,11 +191,11 @@ AE_GROUPS = {
},
},
'board'
:
{
'board'
:
{
'id'
:
2
,
'id'
:
2
,
'name'
:
"ae
_bureau
"
,
'name'
:
"ae
-board
"
,
},
},
'members'
:
{
'members'
:
{
'id'
:
3
,
'id'
:
3
,
'name'
:
"ae
_
memb
r
es"
,
'name'
:
"ae
-
membe
r
s"
,
},
},
'public'
:
{
'public'
:
{
'id'
:
4
,
'id'
:
4
,
...
...
Write
Preview
Supports
Markdown
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