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
f230fbc1
Commit
f230fbc1
authored
Jul 27, 2016
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add product management views
parent
4408890a
Pipeline
#73
failed with stage
in 2 minutes and 3 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
98 additions
and
10 deletions
+98
-10
club/views.py
club/views.py
+2
-2
core/migrations/0008_pagerev_revision.py
core/migrations/0008_pagerev_revision.py
+20
-0
core/models.py
core/models.py
+3
-0
core/templates/core/base.jinja
core/templates/core/base.jinja
+1
-0
core/templates/core/macros.jinja
core/templates/core/macros.jinja
+3
-0
core/templates/core/page_detail.jinja
core/templates/core/page_detail.jinja
+1
-1
core/templates/core/page_hist.jinja
core/templates/core/page_hist.jinja
+11
-7
core/templates/core/user_tools.jinja
core/templates/core/user_tools.jinja
+1
-0
counter/models.py
counter/models.py
+3
-0
counter/templates/counter/product_list.jinja
counter/templates/counter/product_list.jinja
+23
-0
counter/urls.py
counter/urls.py
+3
-0
counter/views.py
counter/views.py
+27
-0
No files found.
club/views.py
View file @
f230fbc1
...
...
@@ -10,14 +10,14 @@ from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin
from
club.models
import
Club
,
Membership
from
sith.settings
import
SITH_MAXIMUM_FREE_ROLE
,
SITH_MAIN_BOARD_GROUP
class
ClubListView
(
CanViewMixin
,
ListView
):
class
ClubListView
(
ListView
):
"""
List the Clubs
"""
model
=
Club
template_name
=
'club/club_list.jinja'
class
ClubView
(
CanViewMixin
,
DetailView
):
class
ClubView
(
DetailView
):
"""
Front page of a Club
"""
...
...
core/migrations/0008_pagerev_revision.py
0 → 100644
View file @
f230fbc1
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'core'
,
'0007_user_is_superuser'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'pagerev'
,
name
=
'revision'
,
field
=
models
.
IntegerField
(
default
=
1
,
verbose_name
=
'revision'
),
preserve_default
=
False
,
),
]
core/models.py
View file @
f230fbc1
...
...
@@ -457,6 +457,7 @@ class PageRev(models.Model):
is the real content of the page.
The content is in PageRev.title and PageRev.content .
"""
revision
=
models
.
IntegerField
(
_
(
"revision"
))
title
=
models
.
CharField
(
_
(
"page title"
),
max_length
=
255
,
blank
=
True
)
content
=
models
.
TextField
(
_
(
"page content"
),
blank
=
True
)
date
=
models
.
DateTimeField
(
_
(
'date'
),
auto_now
=
True
)
...
...
@@ -488,6 +489,8 @@ class PageRev(models.Model):
return
object
.
__getattribute__
(
self
,
attr
)
def
save
(
self
,
*
args
,
**
kwargs
):
if
self
.
revision
is
None
:
self
.
revision
=
self
.
page
.
revisions
.
all
().
count
()
+
1
super
(
PageRev
,
self
).
save
(
*
args
,
**
kwargs
)
# Don't forget to unlock, otherwise, people will have to wait for the page's timeout
self
.
page
.
unset_lock
()
...
...
core/templates/core/base.jinja
View file @
f230fbc1
...
...
@@ -30,6 +30,7 @@
<a
href=
"
{{
url
(
'core:page'
,
page_name
=
"Index"
)
}}
"
>
{%
trans
%}
Wiki
{%
endtrans
%}
</a>
<a
href=
"
{{
url
(
'core:page_list'
)
}}
"
>
{%
trans
%}
Pages
{%
endtrans
%}
</a>
<a
href=
"
{{
url
(
'club:club_list'
)
}}
"
>
{%
trans
%}
Clubs
{%
endtrans
%}
</a>
<a
href=
"
{{
url
(
'core:page'
,
"Services"
)
}}
"
>
{%
trans
%}
Services
{%
endtrans
%}
</a>
</nav>
<div
id=
"content"
>
...
...
core/templates/core/macros.jinja
0 → 100644
View file @
f230fbc1
{%
macro
user_profile_link
(
user
)
-
%}
<a
href=
"
{{
url
(
"core:user_profile"
,
user_id
=
user.id
)
}}
"
>
{{
user.get_display_name
()
}}
</a>
{%
-
endmacro
%}
core/templates/core/page_detail.jinja
View file @
f230fbc1
...
...
@@ -2,7 +2,7 @@
{%
block
page
%}
{%
if
rev
%}
<h4>
{%
trans
rev_id
=
rev.
id
%}
This may not be the last update, you are seeing revision
{{
rev_id
}}
!
{%
endtrans
%}
</h4>
<h4>
{%
trans
rev_id
=
rev.
revision
%}
This may not be the last update, you are seeing revision
{{
rev_id
}}
!
{%
endtrans
%}
</h4>
<h3>
{{
rev.title
}}
</h3>
<div
class=
"page_content"
>
{{
rev.content
|
markdown
}}
</div>
{%
else
%}
...
...
core/templates/core/page_hist.jinja
View file @
f230fbc1
{%
extends
"core/page.jinja"
%}
{%
from
"core/macros.jinja"
import
user_profile_link
%}
{%
block
page
%}
<h3>
{%
trans
%}
Page history
{%
endtrans
%}
</h3>
<h3>
{%
trans
%}
Page history
{%
endtrans
%}
</h3>
<p>
{%
trans
page_name
=
page.name
%}
You're seeing the history of page "
{{
page_name
}}
"
{%
endtrans
%}
</p>
<ul>
{%
for
r
in
(
page.revisions.all
()
|
sort
(
attribute
=
'date'
,
reverse
=
True
))
%}
{%
for
r
in
(
page.revisions.all
()
|
sort
(
attribute
=
'date'
,
reverse
=
True
))
%}
{%
if
loop.index
<
2
%}
<li><a
href=
"
{{
url
(
'core:page'
,
page_name
=
page.get_full_name
())
}}
"
>
last -
{{
page.revisions.last
()
.
author
}}
-
{{
page.revisions.last
()
.
date
|
date
(
'Y-m-d H:i'
)
}}
</a></li>
<li><a
href=
"
{{
url
(
'core:page'
,
page_name
=
page.get_full_name
())
}}
"
>
{%
trans
%}
last
{%
endtrans
%}
</a>
-
{{
user_profile_link
(
page.revisions.last
()
.
author
)
}}
-
{{
page.revisions.last
()
.
date
|
localtime
|
date
(
DATETIME_FORMAT
)
}}
{{
page.revisions.last
()
.
date
|
localtime
|
time
(
DATETIME_FORMAT
)
}}
</a></li>
{%
else
%}
<li><a
href=
"
{{
url
(
'core:page_rev'
,
page_name
=
page.get_full_name
(),
rev
=
r
[
'id'
])
}}
"
>
{{
r
[
'author'
]
}}
-
{{
r
[
'date'
]
|
date
(
'Y-m-d H:i'
)
}}
</a></li>
<li><a
href=
"
{{
url
(
'core:page_rev'
,
page_name
=
page.get_full_name
(),
rev
=
r
[
'id'
])
}}
"
>
{{
r.revision
}}
</a>
-
{{
user_profile_link
(
r.author
)
}}
-
{{
page.revisions.last
()
.
date
|
localtime
|
date
(
DATETIME_FORMAT
)
}}
{{
page.revisions.last
()
.
date
|
localtime
|
time
(
DATETIME_FORMAT
)
}}
</a></li>
{%
endif
%}
{%
endfor
%}
{%
endfor
%}
</ul>
{%
endblock
%}
...
...
core/templates/core/user_tools.jinja
View file @
f230fbc1
...
...
@@ -23,6 +23,7 @@
<ul>
{%
if
user.is_in_group
(
settings.SITH_GROUPS
[
'counter-admin'
][
'name'
])
or
user.is_in_group
(
settings.SITH_GROUPS
[
'root'
][
'name'
])
%}
<li><a
href=
"
{{
url
(
'counter:admin_list'
)
}}
"
>
{%
trans
%}
General counters management
{%
endtrans
%}
</a></li>
<li><a
href=
"
{{
url
(
'counter:product_list'
)
}}
"
>
{%
trans
%}
General products management
{%
endtrans
%}
</a></li>
{%
endif
%}
{%
for
b
in
settings.SITH_COUNTER_BARS
%}
{%
if
user.is_in_group
(
b
[
1
]
+
" admin"
)
%}
...
...
counter/models.py
View file @
f230fbc1
...
...
@@ -75,6 +75,9 @@ class Product(models.Model):
def
__str__
(
self
):
return
self
.
name
def
get_absolute_url
(
self
):
return
reverse
(
'counter:product_list'
)
class
Counter
(
models
.
Model
):
name
=
models
.
CharField
(
_
(
'name'
),
max_length
=
30
)
club
=
models
.
ForeignKey
(
Club
,
related_name
=
"counters"
)
...
...
counter/templates/counter/product_list.jinja
0 → 100644
View file @
f230fbc1
{%
extends
"core/base.jinja"
%}
{%
block
title
%}
{%
trans
%}
Product list
{%
endtrans
%}
{%
endblock
%}
{%
block
content
%}
<p><a
href=
"
{{
url
(
'counter:new_product'
)
}}
"
>
{%
trans
%}
New product
{%
endtrans
%}
</a></p>
{%
if
product_list
%}
<h3>
{%
trans
%}
Product list
{%
endtrans
%}
</h3>
<ul>
{%
for
p
in
product_list
%}
<li><a
href=
"
{{
url
(
'counter:product_edit'
,
product_id
=
p.id
)
}}
"
>
{{
p
}}
</a></li>
{%
endfor
%}
</ul>
{%
else
%}
{%
trans
%}
There is no products in this website.
{%
endtrans
%}
{%
endif
%}
{%
endblock
%}
counter/urls.py
View file @
f230fbc1
...
...
@@ -11,6 +11,9 @@ urlpatterns = [
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'
),
url
(
r
'^admin/product/list$'
,
ProductListView
.
as_view
(),
name
=
'product_list'
),
url
(
r
'^admin/product/create$'
,
ProductCreateView
.
as_view
(),
name
=
'new_product'
),
url
(
r
'^admin/product/(?P<product_id>[0-9]+)$'
,
ProductEditView
.
as_view
(),
name
=
'product_edit'
),
]
counter/views.py
View file @
f230fbc1
...
...
@@ -351,6 +351,33 @@ class CounterDeleteView(CanEditMixin, DeleteView):
template_name
=
'core/delete_confirm.jinja'
success_url
=
reverse_lazy
(
'counter:admin_list'
)
# Product management
class
ProductListView
(
ListView
):
"""
A list view for the admins
"""
model
=
Product
template_name
=
'counter/product_list.jinja'
class
ProductCreateView
(
CreateView
):
"""
A create view for the admins
"""
model
=
Product
template_name
=
'core/edit.jinja'
class
ProductEditView
(
UpdateView
):
"""
An edit view for the admins
"""
model
=
Product
form_class
=
modelform_factory
(
Product
,
fields
=
[
'name'
,
'description'
,
'product_type'
,
'code'
,
'purchase_price'
,
'selling_price'
,
'special_selling_price'
,
'icon'
,
'club'
])
pk_url_kwarg
=
"product_id"
template_name
=
'core/edit.jinja'
# TODO: add management of the 'counters' ForeignKey
# User accounting infos
class
UserAccountView
(
DetailView
):
...
...
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