Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
oser-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hamza Touizrat
oser-backend
Commits
25a48917
Commit
25a48917
authored
Feb 25, 2018
by
florimondmanca
Browse files
Options
Downloads
Patches
Plain Diff
update Place admin
parent
ba6372bf
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
oser_backend/visits/admin.py
+7
-2
7 additions, 2 deletions
oser_backend/visits/admin.py
oser_backend/visits/models.py
+8
-5
8 additions, 5 deletions
oser_backend/visits/models.py
with
15 additions
and
7 deletions
oser_backend/visits/admin.py
+
7
−
2
View file @
25a48917
...
@@ -84,8 +84,13 @@ class VisitAdmin(admin.ModelAdmin):
...
@@ -84,8 +84,13 @@ class VisitAdmin(admin.ModelAdmin):
class
PlaceAdmin
(
admin
.
ModelAdmin
):
class
PlaceAdmin
(
admin
.
ModelAdmin
):
"""
Admin panel for places.
"""
"""
Admin panel for places.
"""
list_display
=
(
'
id
'
,
'
__str__
'
,
'
address
'
,
'
num_visits
'
)
list_display
=
(
'
name
'
,
'
address
'
,
'
num_visits
'
,
'
last_visit
'
)
list_display_links
=
(
'
name
'
,
'
last_visit
'
)
def
num_visits
(
self
,
obj
):
def
num_visits
(
self
,
obj
):
return
obj
.
visit_set
.
count
()
return
obj
.
visit_set
.
count
()
num_visits
.
short_description
=
'
Sorties ici
'
num_visits
.
short_description
=
'
Nombre de sorties
'
def
last_visit
(
self
,
obj
):
return
obj
.
visit_set
.
passed
().
order_by
(
'
date
'
).
first
()
last_visit
.
short_description
=
'
Dernière sortie
'
This diff is collapsed.
Click to expand it.
oser_backend/visits/models.py
+
8
−
5
View file @
25a48917
"""
Visits models.
"""
"""
Visits models.
"""
import
pytz
import
pytz
from
django.utils
import
timezone
from
django.utils
.timezone
import
now
from
django.db
import
models
from
django.db
import
models
from
django.shortcuts
import
reverse
from
django.shortcuts
import
reverse
from
dry_rest_permissions.generics
import
authenticated_users
from
dry_rest_permissions.generics
import
authenticated_users
...
@@ -28,11 +28,14 @@ class VisitQuerySet(models.QuerySet):
...
@@ -28,11 +28,14 @@ class VisitQuerySet(models.QuerySet):
True corresponds to open registrations,
True corresponds to open registrations,
False to closed registrations.
False to closed registrations.
"""
"""
now
=
timezone
.
now
()
dt_
now
=
now
()
if
state
:
if
state
:
return
self
.
filter
(
deadline__gte
=
now
)
return
self
.
filter
(
deadline__gte
=
dt_
now
)
else
:
else
:
return
self
.
filter
(
deadline__lt
=
now
)
return
self
.
filter
(
deadline__lt
=
dt_now
)
def
passed
(
self
):
return
self
.
filter
(
date__gt
=
now
())
class
VisitParticipant
(
models
.
Model
):
class
VisitParticipant
(
models
.
Model
):
...
@@ -130,7 +133,7 @@ class Visit(models.Model):
...
@@ -130,7 +133,7 @@ class Visit(models.Model):
through
=
'
VisitParticipant
'
)
through
=
'
VisitParticipant
'
)
def
_registrations_open
(
self
):
def
_registrations_open
(
self
):
return
timezone
.
now
()
<
self
.
deadline
return
now
()
<
self
.
deadline
# to display fancy icon instead of True/False
# to display fancy icon instead of True/False
_registrations_open
.
boolean
=
True
_registrations_open
.
boolean
=
True
# don't define property directly because prop.fget.boolean doesn't work
# don't define property directly because prop.fget.boolean doesn't work
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment