Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
site-kwei
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aeltheos
site-kwei
Commits
614ddd03
Commit
614ddd03
authored
3 years ago
by
Dorian Lesbre
Browse files
Options
Downloads
Patches
Plain Diff
Shift planning break from midnight to 4am
parent
11e55f3c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
home/models.py
+53
-5
53 additions, 5 deletions
home/models.py
home/templates/_planning.html
+16
-16
16 additions, 16 deletions
home/templates/_planning.html
site_settings/models.py
+8
-0
8 additions, 0 deletions
site_settings/models.py
with
77 additions
and
21 deletions
home/models.py
+
53
−
5
View file @
614ddd03
import
datetime
from
django.db
import
models
from
django.utils.translation
import
gettext_lazy
as
_
from
django.utils
import
timezone
from
accounts.models
import
EmailUser
from
site_settings.models
import
SiteSettings
class
InterludesActivity
(
models
.
Model
):
"""
une activité des interludes (i.e. JDR, murder)...
"""
...
...
@@ -138,7 +142,7 @@ class InterludesSlot(models.Model):
help_text
=
"
Utilisez
'
{}
'
pour insérer le titre de l
'
activité correspondante
"
.
format
(
TITLE_SPECIFIER
),
)
start
=
models
.
DateTimeField
(
"
début
"
,
null
=
True
,
blank
=
True
)
start
=
models
.
DateTimeField
(
"
début
"
)
room
=
models
.
CharField
(
"
salle
"
,
max_length
=
100
,
null
=
True
,
blank
=
True
)
on_planning
=
models
.
BooleanField
(
"
afficher sur le planning
"
,
default
=
False
,
...
...
@@ -158,18 +162,62 @@ class InterludesSlot(models.Model):
@property
def
end
(
self
):
"""
Heure de fin du créneau
"""
if
(
not
self
.
start
)
or
(
not
self
.
activity
.
duration
):
return
None
return
self
.
start
+
self
.
activity
.
duration
def
conflicts
(
self
,
other
:
"
InterludesSlot
"
)
->
bool
:
"""
Check whether these slots overlap
"""
if
self
.
end
is
None
or
other
.
end
is
None
:
return
False
if
self
.
start
<=
other
.
start
:
return
other
.
start
<=
self
.
end
return
self
.
start
<=
other
.
end
@staticmethod
def
relative_day
(
date
:
datetime
.
datetime
)
->
int
:
"""
Relative day to start.
- friday 04:00 -> 03:59 = day 0
- saturday 04:00 -> 03:59 = day 1
- sunday 04:00 -> 03:59 = day 2
returns 0 if no date_start is defined in settings
"""
settings
=
SiteSettings
.
load
()
if
settings
.
date_start
:
return
(
date
-
timezone
.
datetime
.
combine
(
settings
.
date_start
,
datetime
.
time
(
hour
=
4
),
timezone
.
get_current_timezone
()
)).
days
else
:
return
0
@staticmethod
def
fake_date
(
date
:
datetime
.
datetime
):
"""
Fake day for display on the (single day planning)
"""
print
(
"
hllo!!!! ================
"
)
settings
=
SiteSettings
.
load
()
if
settings
.
date_start
:
x
=
timezone
.
datetime
.
combine
(
settings
.
date_start
,
date
.
time
(),
timezone
.
get_current_timezone
()
)
print
(
x
)
return
x
return
None
@property
def
start_day
(
self
)
->
int
:
"""
returns a day (0-2)
"""
return
self
.
relative_day
(
self
.
start
)
@property
def
end_day
(
self
)
->
int
:
"""
returns a day (0-2)
"""
return
self
.
relative_day
(
self
.
end
)
@property
def
planning_start
(
self
)
->
int
:
return
self
.
fake_date
(
self
.
start
)
@property
def
planning_end
(
self
)
->
int
:
return
self
.
fake_date
(
self
.
end
)
def
__str__
(
self
)
->
str
:
return
self
.
title
.
replace
(
self
.
TITLE_SPECIFIER
,
self
.
activity
.
title
)
...
...
This diff is collapsed.
Click to expand it.
home/templates/_planning.html
+
16
−
16
View file @
614ddd03
...
...
@@ -9,41 +9,41 @@ I.E we set all dates to the first day (Friday) and set groups allowing vertical
const
container
=
document
.
getElementById
(
'
planning
'
);
const
groups
=
new
vis
.
DataSet
([
{
id
:
{{
friday
}}
,
content
:
"
Ven.
"
,
order
:
0
},
{
id
:
{{
saturday
}}
,
content
:
"
Sam.
"
,
order
:
1
},
{
id
:
{{
sunday
}}
,
content
:
"
Dim.
"
,
order
:
2
},
{
id
:
0
,
content
:
"
Ven.
"
,
order
:
0
},
{
id
:
1
,
content
:
"
Sam.
"
,
order
:
1
},
{
id
:
2
,
content
:
"
Dim.
"
,
order
:
2
},
]);
// Items in the timeline
const
items
=
new
vis
.
DataSet
([
{
%
for
slot
in
planning
%
}
{
%
if
slot
.
start
|
da
te
:
"
d
"
==
slot
.
end
|
da
te
:
"
d
"
%
}
{
%
if
slot
.
start
_
da
y
==
slot
.
end
_
da
y
%
}
{
content
:
'
<div style="background-color: yellow;"><a class="hidden" href="#{{ slot.activity.slug }}"><div><strong>{{ slot }}</strong><br>{{ slot.room|default:"" }}</div></a></div>
'
,
title
:
'
<strong>{{ slot }}</strong><br>{{ slot.room|default:"" }}
'
,
start
:
'
{{ s
ettings.date
_start|date:"Y-m-d
"}} {{ slot.start|date:"
H:i:s"
}}
'
,
start
:
'
{{ s
lot.planning
_start|date:"Y-m-d
H:i:s"}}
'
,
align
:
'
left
'
,
group
:
{{
slot
.
start
|
da
te
:
"
d
"
}},
end
:
'
{{ s
ettings.date_start|date:"Y-m-d"}} {{ slot.end|date:"
H:i:s"
}}
'
,
group
:
{{
slot
.
start
_
da
y
}},
end
:
'
{{ s
lot.planning_end|date:"Y-m-d
H:i:s"}}
'
,
className
:
"
color-{{ slot.color }}
"
,
},
{
%
else
%
}
// activity spans multiple days
{
content
:
'
<a class="hidden" href="#{{ slot.activity.slug }}"><div><strong>{{ slot }}</strong><br>{{ slot.room|default:"" }}</div></a>
'
,
title
:
'
<strong>{{ slot }}</strong><br>{{ slot.room|default:"" }}
'
,
start
:
'
{{ s
ettings.date
_start|date:"Y-m-d
"}} {{ slot.start|date:"
H:i:s"
}}
'
,
start
:
'
{{ s
lot.planning
_start|date:"Y-m-d
H:i:s"}}
'
,
align
:
'
left
'
,
group
:
{{
slot
.
start
|
da
te
:
"
d
"
}},
end
:
'
{{ settings.date_
start
|date:"Y-m-d"}}
23:59:59
'
,
group
:
{{
slot
.
start
_
da
y
}},
end
:
'
{{ settings.date_
2
|date:"Y-m-d"}}
04:00:00
'
,
className
:
"
color-{{ slot.color }}
"
,
},
{
content
:
'
<a class="hidden" href="#{{ slot.activity.slug }}"><div><strong>{{ slot }}</strong><br>{{ slot.room|default:"" }}</div></a>
'
,
title
:
'
<strong>{{ slot }}</strong><br>{{ slot.room|default:"" }}
'
,
start
:
'
{{ settings.date_start|date:"Y-m-d"}} 0
0
:00:00
'
,
start
:
'
{{ settings.date_start|date:"Y-m-d"}} 0
4
:00:00
'
,
align
:
'
left
'
,
group
:
{{
slot
.
start
|
date
:
"
d
"
|
add
:
"
1
"
}},
end
:
'
{{ s
ettings.date_start|date:"Y-m-d"}} {{ slot.end|date:"
H:i:s"
}}
'
,
group
:
{{
slot
.
end_day
}},
end
:
'
{{ s
lot.planning_end|date:"Y-m-d
H:i:s"}}
'
,
className
:
"
color-{{ slot.color }}
"
,
},
{
%
endif
%
}
...
...
@@ -51,8 +51,8 @@ I.E we set all dates to the first day (Friday) and set groups allowing vertical
]);
// Configuration for the Timeline
const
start
=
'
{{ settings.date_start|date:"Y-m-d"}} 0
0
:00:00
'
;
const
end
=
'
{{ settings.date_start|date:"Y-m
-d"}} 23:59:59
'
;
const
start
=
'
{{ settings.date_start|date:"Y-m-d"}} 0
4
:00:00
'
;
const
end
=
'
{{ settings.date_start|date:"Y-m
"}}-{{ saturday }} 04:00:00
'
;
const
options
=
{
showMajorLabels
:
false
,
showCurrentTime
:
false
,
...
...
@@ -84,7 +84,7 @@ I.E we set all dates to the first day (Friday) and set groups allowing vertical
.vis-item
a
,
.vis-item
a
:link
,
.vis-item
a
:visited
{
text-decoration
:
none
;
color
:
white
;
width
:
100%
width
:
100%
;
}
.vis-item
a
div
{
width
:
100%
;
...
...
This diff is collapsed.
Click to expand it.
site_settings/models.py
+
8
−
0
View file @
614ddd03
from
datetime
import
timedelta
from
django.db
import
models
from
django.core.cache
import
cache
from
django.utils.timezone
import
now
...
...
@@ -107,6 +109,12 @@ class SiteSettings(SingletonModel):
return
now
()
>=
self
.
inscriptions_end
return
False
@property
def
date_2
(
self
):
"""
The date of the second day
"""
if
self
.
date_start
:
return
self
.
date_start
+
timedelta
(
days
=
1
)
class
Meta
:
verbose_name
=
"
paramètres
"
verbose_name_plural
=
"
paramètres
"
...
...
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