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-emissions
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
Incidents
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-emissions
Commits
9512f287
Commit
9512f287
authored
Sep 26, 2019
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mark models with @python_2_unicode_compatible
parent
3dfdf997
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
13 deletions
+28
-13
emissions/models.py
emissions/models.py
+28
-13
No files found.
emissions/models.py
View file @
9512f287
...
...
@@ -7,6 +7,7 @@ from django.forms import fields
from
django.core.urlresolvers
import
reverse
from
django.db
import
models
from
django.utils.encoding
import
python_2_unicode_compatible
from
django.utils.translation
import
ugettext
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
@@ -50,6 +51,7 @@ class WeekdayMixin(object):
return
week_day
==
day
@
python_2_unicode_compatible
class
Category
(
models
.
Model
):
class
Meta
:
...
...
@@ -64,10 +66,11 @@ class Category(models.Model):
def
sorted_emission
(
self
):
return
self
.
emission_set
.
order_by
(
'title'
)
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
self
.
title
@
python_2_unicode_compatible
class
Colour
(
models
.
Model
):
class
Meta
:
...
...
@@ -81,10 +84,11 @@ class Colour(models.Model):
def
sorted_emission
(
self
):
return
self
.
emission_set
.
order_by
(
'title'
)
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
self
.
title
@
python_2_unicode_compatible
class
Format
(
models
.
Model
):
class
Meta
:
...
...
@@ -95,7 +99,7 @@ class Format(models.Model):
title
=
models
.
CharField
(
_
(
'Title'
),
max_length
=
50
)
slug
=
models
.
SlugField
(
null
=
True
)
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
self
.
title
...
...
@@ -104,6 +108,7 @@ def get_emission_image_path(instance, filename):
os
.
path
.
basename
(
filename
))
@
python_2_unicode_compatible
class
Emission
(
models
.
Model
):
class
Meta
:
...
...
@@ -144,7 +149,7 @@ class Emission(models.Model):
def
get_absolute_url
(
self
):
return
reverse
(
'emission-view'
,
kwargs
=
{
'slug'
:
str
(
self
.
slug
)})
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
self
.
title
def
save
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -186,6 +191,7 @@ class Emission(models.Model):
return
possible_dates
[
0
]
@
python_2_unicode_compatible
class
Schedule
(
models
.
Model
,
WeekdayMixin
):
class
Meta
:
...
...
@@ -274,7 +280,7 @@ class Schedule(models.Model, WeekdayMixin):
return
possible_dates
[
0
]
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
u
'%s at %s'
%
(
self
.
emission
.
title
,
self
.
datetime
.
strftime
(
'%a %H:%M'
))
...
...
@@ -284,6 +290,7 @@ def get_episode_image_path(instance, filename):
os
.
path
.
basename
(
filename
))
@
python_2_unicode_compatible
class
Episode
(
models
.
Model
):
class
Meta
:
...
...
@@ -315,7 +322,7 @@ class Episode(models.Model):
# XXX: languages (models.ManyToManyField(Language))
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
self
.
title
def
save
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -386,6 +393,7 @@ class Episode(models.Model):
return
Diffusion
.
objects
.
filter
(
episode
=
self
.
id
).
order_by
(
'datetime'
)
@
python_2_unicode_compatible
class
Diffusion
(
models
.
Model
,
WeekdayMixin
):
class
Meta
:
...
...
@@ -395,7 +403,7 @@ class Diffusion(models.Model, WeekdayMixin):
episode
=
models
.
ForeignKey
(
'Episode'
,
verbose_name
=
_
(
'Episode'
))
datetime
=
models
.
DateTimeField
(
_
(
'Date/time'
),
db_index
=
True
)
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
u
'%s at %02d:%02d'
%
(
self
.
episode
.
title
,
self
.
datetime
.
hour
,
self
.
datetime
.
minute
)
...
...
@@ -406,6 +414,7 @@ class Diffusion(models.Model, WeekdayMixin):
return
self
.
datetime
+
datetime
.
timedelta
(
minutes
=
self
.
get_duration
())
@
python_2_unicode_compatible
class
Absence
(
models
.
Model
):
class
Meta
:
...
...
@@ -415,7 +424,7 @@ class Absence(models.Model):
emission
=
models
.
ForeignKey
(
'Emission'
,
verbose_name
=
u
'Emission'
)
datetime
=
models
.
DateTimeField
(
_
(
'Date/time'
),
db_index
=
True
)
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
u
'Absence for %s on %s'
%
(
self
.
emission
.
title
,
self
.
datetime
)
...
...
@@ -423,6 +432,8 @@ def get_sound_path(instance, filename):
return
os
.
path
.
join
(
'sounds.orig'
,
instance
.
episode
.
emission
.
slug
,
os
.
path
.
basename
(
filename
))
@
python_2_unicode_compatible
class
SoundFile
(
models
.
Model
):
class
Meta
:
...
...
@@ -472,10 +483,11 @@ class SoundFile(models.Model):
return
''
return
'%d:%02d'
%
(
self
.
duration
/
60
,
self
.
duration
%
60
)
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
'%s - %s'
%
(
self
.
title
or
self
.
id
,
self
.
episode
.
title
)
@
python_2_unicode_compatible
class
NewsCategory
(
models
.
Model
):
class
Meta
:
...
...
@@ -486,7 +498,7 @@ class NewsCategory(models.Model):
title
=
models
.
CharField
(
_
(
'Title'
),
max_length
=
50
)
slug
=
models
.
SlugField
(
null
=
True
)
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
self
.
title
def
get_sorted_newsitems
(
self
):
...
...
@@ -498,6 +510,7 @@ def get_newsitem_image_path(instance, filename):
os
.
path
.
basename
(
filename
))
@
python_2_unicode_compatible
class
NewsItem
(
models
.
Model
):
class
Meta
:
...
...
@@ -528,13 +541,14 @@ class NewsItem(models.Model):
creation_timestamp
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
)
last_update_timestamp
=
models
.
DateTimeField
(
auto_now
=
True
,
null
=
True
)
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
self
.
title
def
get_absolute_url
(
self
):
return
reverse
(
'newsitem-view'
,
kwargs
=
{
'slug'
:
str
(
self
.
slug
)})
@
python_2_unicode_compatible
class
Nonstop
(
models
.
Model
):
class
Meta
:
...
...
@@ -550,10 +564,11 @@ class Nonstop(models.Model):
text
=
RichTextField
(
_
(
'Description'
),
null
=
True
,
blank
=
True
)
redirect_path
=
models
.
CharField
(
_
(
'Redirect Path'
),
max_length
=
200
,
blank
=
True
)
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
return
self
.
title
@
python_2_unicode_compatible
class
Focus
(
models
.
Model
):
title
=
models
.
CharField
(
_
(
'Alternate Title'
),
max_length
=
50
,
null
=
True
,
blank
=
True
)
...
...
@@ -572,7 +587,7 @@ class Focus(models.Model):
creation_timestamp
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
)
last_update_timestamp
=
models
.
DateTimeField
(
auto_now
=
True
,
null
=
True
)
def
__
unicode
__
(
self
):
def
__
str
__
(
self
):
if
self
.
newsitem
:
return
u
'Newsitem: %s'
%
self
.
newsitem
.
title
if
self
.
emission
:
...
...
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