Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
django-panik-nonstop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
radiopanik
django-panik-nonstop
Commits
e9ca58ae
Commit
e9ca58ae
authored
Oct 03, 2017
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make it possible to edit all custom metadata
parent
936ed488
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
7 deletions
+9
-7
nonstop/forms.py
nonstop/forms.py
+2
-2
nonstop/models.py
nonstop/models.py
+2
-0
nonstop/templates/nonstop/track_detail.html
nonstop/templates/nonstop/track_detail.html
+1
-1
nonstop/views.py
nonstop/views.py
+4
-4
No files found.
nonstop/forms.py
View file @
e9ca58ae
...
@@ -15,7 +15,7 @@ class UploadTracksForm(forms.Form):
...
@@ -15,7 +15,7 @@ class UploadTracksForm(forms.Form):
nonstop_zone
=
forms
.
ChoiceField
(
choices
=
get_optional_nonstop_zones
)
nonstop_zone
=
forms
.
ChoiceField
(
choices
=
get_optional_nonstop_zones
)
class
NonstopZones
Form
(
forms
.
ModelForm
):
class
TrackMeta
Form
(
forms
.
ModelForm
):
class
Meta
:
class
Meta
:
model
=
Track
model
=
Track
fields
=
[
'nonstop_zones'
]
fields
=
[
'
language'
,
'instru'
,
'sabam'
,
'cfwb'
,
'
nonstop_zones'
]
nonstop/models.py
View file @
e9ca58ae
...
@@ -75,6 +75,8 @@ class Track(models.Model):
...
@@ -75,6 +75,8 @@ class Track(models.Model):
return
os
.
path
.
exists
(
self
.
nonstopfile_set
.
order_by
(
'creation_timestamp'
)
.
last
()
.
get_local_filepath
())
return
os
.
path
.
exists
(
self
.
nonstopfile_set
.
order_by
(
'creation_timestamp'
)
.
last
()
.
get_local_filepath
())
def
sync_nonstop_zones
(
self
):
def
sync_nonstop_zones
(
self
):
if
not
self
.
file_exists
():
return
nonstop_file
=
self
.
nonstopfile_set
.
order_by
(
'creation_timestamp'
)
.
last
()
nonstop_file
=
self
.
nonstopfile_set
.
order_by
(
'creation_timestamp'
)
.
last
()
filename
=
nonstop_file
.
filename
filename
=
nonstop_file
.
filename
current_zones
=
self
.
nonstop_zones
.
all
()
current_zones
=
self
.
nonstop_zones
.
all
()
...
...
nonstop/templates/nonstop/track_detail.html
View file @
e9ca58ae
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
{% if object.file_exists %}
{% if object.file_exists %}
<form
method=
"POST"
>
<form
method=
"POST"
>
{% csrf_token %}
{% csrf_token %}
{{
zones
_form.as_p }}
{{
metadata
_form.as_p }}
<div
class=
"buttons"
>
<div
class=
"buttons"
>
<button
class=
"submit-button"
>
{% trans "Update" %}
</button>
<button
class=
"submit-button"
>
{% trans "Update" %}
</button>
</div>
</div>
...
...
nonstop/views.py
View file @
e9ca58ae
...
@@ -18,7 +18,7 @@ from django.views.generic.detail import DetailView
...
@@ -18,7 +18,7 @@ from django.views.generic.detail import DetailView
from
django.views.generic.edit
import
FormView
from
django.views.generic.edit
import
FormView
from
django.views.generic.list
import
ListView
from
django.views.generic.list
import
ListView
from
.forms
import
UploadTracksForm
,
NonstopZones
Form
from
.forms
import
UploadTracksForm
,
TrackMeta
Form
from
.models
import
SomaLogLine
,
Track
,
Artist
,
NonstopFile
from
.models
import
SomaLogLine
,
Track
,
Artist
,
NonstopFile
from
emissions.models
import
Nonstop
from
emissions.models
import
Nonstop
...
@@ -63,14 +63,14 @@ class TrackDetailView(DetailView):
...
@@ -63,14 +63,14 @@ class TrackDetailView(DetailView):
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
ctx
=
super
(
TrackDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
ctx
=
super
(
TrackDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
ctx
[
'
zones_form'
]
=
NonstopZones
Form
(
instance
=
self
.
object
)
ctx
[
'
metadata_form'
]
=
TrackMeta
Form
(
instance
=
self
.
object
)
return
ctx
return
ctx
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
instance
=
self
.
get_object
()
instance
=
self
.
get_object
()
old_nonstop_zones
=
copy
.
copy
(
instance
.
nonstop_zones
.
all
())
old_nonstop_zones
=
copy
.
copy
(
instance
.
nonstop_zones
.
all
())
zones_form
=
NonstopZones
Form
(
request
.
POST
,
instance
=
instance
)
form
=
TrackMeta
Form
(
request
.
POST
,
instance
=
instance
)
zones_
form
.
save
()
form
.
save
()
new_nonstop_zones
=
self
.
get_object
()
.
nonstop_zones
.
all
()
new_nonstop_zones
=
self
.
get_object
()
.
nonstop_zones
.
all
()
if
set
(
old_nonstop_zones
)
!=
set
(
new_nonstop_zones
):
if
set
(
old_nonstop_zones
)
!=
set
(
new_nonstop_zones
):
instance
.
sync_nonstop_zones
()
instance
.
sync_nonstop_zones
()
...
...
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