Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
django-panik-nonstop
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
radiopanik
django-panik-nonstop
Commits
e739141b
Commit
e739141b
authored
Oct 04, 2017
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add timestamp of moment when the file is included in a nonstop zone
parent
c2796785
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
nonstop/migrations/0009_track_added_to_nonstop_timestamp.py
nonstop/migrations/0009_track_added_to_nonstop_timestamp.py
+19
-0
nonstop/models.py
nonstop/models.py
+11
-1
No files found.
nonstop/migrations/0009_track_added_to_nonstop_timestamp.py
0 → 100644
View file @
e739141b
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'nonstop'
,
'0008_track_uploader'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'track'
,
name
=
'added_to_nonstop_timestamp'
,
field
=
models
.
DateTimeField
(
null
=
True
),
),
]
nonstop/models.py
View file @
e739141b
...
...
@@ -5,6 +5,7 @@ import mutagen
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.db
import
models
from
django.utils.timezone
import
now
from
django.utils.translation
import
ugettext_lazy
as
_
REMOTE_BASE_PATH
=
'/srv/soma/nonstop/'
...
...
@@ -58,6 +59,7 @@ class Track(models.Model):
nonstop_zones
=
models
.
ManyToManyField
(
'emissions.Nonstop'
,
blank
=
True
)
creation_timestamp
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
)
added_to_nonstop_timestamp
=
models
.
DateTimeField
(
null
=
True
)
uploader
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
null
=
True
)
class
Meta
:
...
...
@@ -80,11 +82,19 @@ class Track(models.Model):
return
False
def
sync_nonstop_zones
(
self
):
current_zones
=
self
.
nonstop_zones
.
all
()
if
current_zones
.
count
():
if
not
self
.
added_to_nonstop_timestamp
:
self
.
added_to_nonstop_timestamp
=
now
()
self
.
save
()
else
:
self
.
added_to_nonstop_timestamp
=
None
self
.
save
()
if
not
self
.
file_exists
():
return
nonstop_file
=
self
.
nonstopfile_set
.
order_by
(
'creation_timestamp'
).
last
()
filename
=
nonstop_file
.
filename
current_zones
=
self
.
nonstop_zones
.
all
()
from
emissions.models
import
Nonstop
for
zone
in
Nonstop
.
objects
.
all
():
...
...
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