Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
steering
Commits
abadb84d
Commit
abadb84d
authored
8 years ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
limit timeslot, better naming
parent
1d088404
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
program/admin.py
+16
-9
16 additions, 9 deletions
program/admin.py
program/models.py
+2
-2
2 additions, 2 deletions
program/models.py
with
18 additions
and
11 deletions
program/admin.py
+
16
−
9
View file @
abadb84d
...
...
@@ -8,7 +8,7 @@ from datetime import date, datetime, timedelta
class
BroadcastFormatAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'
format
'
,
'
enabled
'
,
'
admin_color
'
)
list_display
=
(
'
format
'
,
'
admin_color
'
,
'
enabled
'
)
prepopulated_fields
=
{
'
slug
'
:
(
'
format
'
,)}
...
...
@@ -29,8 +29,8 @@ class ShowTopicAdmin(admin.ModelAdmin):
class
HostAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'
name
'
,)
list_filter
=
(
'
is_a
lways_visible
'
,
'
is_activ
e
'
)
list_display
=
(
'
name
'
,
'
is_active
'
)
list_filter
=
(
'
is_a
ctive
'
,
'
is_always_visibl
e
'
)
class
NoteAdmin
(
admin
.
ModelAdmin
):
...
...
@@ -45,10 +45,17 @@ class NoteAdmin(admin.ModelAdmin):
return
super
(
NoteAdmin
,
self
).
get_queryset
(
request
).
filter
(
show__in
=
shows
)
def
formfield_for_foreignkey
(
self
,
db_field
,
request
=
None
,
**
kwargs
):
four_weeks
=
datetime
.
now
()
-
timedelta
(
weeks
=
4
)
four_weeks_ago
=
datetime
.
now
()
-
timedelta
(
weeks
=
4
)
in_eight_weeks
=
datetime
.
now
()
+
timedelta
(
weeks
=
8
)
if
db_field
.
name
==
'
timeslot
'
:
shows
=
request
.
user
.
shows
.
all
()
kwargs
[
'
queryset
'
]
=
TimeSlot
.
objects
.
filter
(
show__in
=
shows
,
start__gt
=
four_weeks
)
try
:
timeslot_id
=
int
(
request
.
get_full_path
().
split
(
'
/
'
)[
-
2
])
except
ValueError
:
shows
=
request
.
user
.
shows
.
all
()
kwargs
[
'
queryset
'
]
=
TimeSlot
.
objects
.
filter
(
show__in
=
shows
,
note__isnull
=
True
,
start__gt
=
four_weeks_ago
,
start__lt
=
in_eight_weeks
)
else
:
kwargs
[
'
queryset
'
]
=
TimeSlot
.
objects
.
filter
(
note
=
timeslot_id
)
return
super
(
NoteAdmin
,
self
).
formfield_for_foreignkey
(
db_field
,
request
,
**
kwargs
)
...
...
@@ -66,7 +73,7 @@ class ProgramSlotAdmin(admin.ModelAdmin):
inlines
=
(
TimeSlotInline
,)
fields
=
((
'
rrule
'
,
'
byweekday
'
),
(
'
dstart
'
,
'
tstart
'
,
'
tend
'
),
'
until
'
,
'
is_repetition
'
,
'
automation_id
'
)
list_display
=
(
'
get_show_name
'
,
'
byweekday
'
,
'
rrule
'
,
'
tstart
'
,
'
tend
'
,
'
until
'
)
list_filter
=
(
'
byweekday
'
,
'
rrule
'
,
'
is_repetition
'
,
'
is_active
'
)
list_filter
=
(
'
is_active
'
,
'
byweekday
'
,
'
rrule
'
,
'
is_repetition
'
)
ordering
=
(
'
byweekday
'
,
'
dstart
'
)
save_on_top
=
True
search_fields
=
(
'
show__name
'
,)
...
...
@@ -96,8 +103,8 @@ class ProgramSlotInline(admin.TabularInline):
class
ShowAdmin
(
admin
.
ModelAdmin
):
filter_horizontal
=
(
'
hosts
'
,
'
owners
'
,
'
musicfocus
'
,
'
showinformation
'
,
'
showtopic
'
)
inlines
=
(
ProgramSlotInline
,)
list_display
=
(
'
name
'
,
'
short_description
'
,
'
broadcastformat
'
)
list_filter
=
(
'
broadcastformat
'
,
'
showinformation
'
,
'
showtopic
'
,
'
musicfocus
'
,
'
is_active
'
)
list_display
=
(
'
name
'
,
'
short_description
'
,
'
is_active
'
)
list_filter
=
(
'
is_active
'
,
'
broadcastformat
'
,
'
showinformation
'
,
'
showtopic
'
,
'
musicfocus
'
)
ordering
=
(
'
slug
'
,)
prepopulated_fields
=
{
'
slug
'
:
(
'
name
'
,)}
search_fields
=
(
'
name
'
,
'
short_description
'
,
'
description
'
)
...
...
This diff is collapsed.
Click to expand it.
program/models.py
+
2
−
2
View file @
abadb84d
...
...
@@ -465,10 +465,10 @@ class TimeSlot(models.Model):
verbose_name_plural
=
_
(
"
Time slots
"
)
def
__unicode__
(
self
):
start
=
self
.
start
.
strftime
(
'
%d.
%b
%Y %H:%M
'
)
start
=
self
.
start
.
strftime
(
'
%d.
%m.
%Y %H:%M
'
)
end
=
self
.
end
.
strftime
(
'
%H:%M
'
)
return
u
'
%s
:
%s
-
%s
'
%
(
s
elf
.
show
,
start
,
end
)
return
u
'
%s
-
%s
|
%s
'
%
(
s
tart
,
end
,
self
.
show
.
name
)
def
save
(
self
,
*
args
,
**
kwargs
):
self
.
show
=
self
.
programslot
.
show
...
...
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