Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Chronos
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Chronos
Commits
e494f43a
Verified
Commit
e494f43a
authored
5 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Include calendar week selects and prev/next buttons in plan.html
parent
e81ba896
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!31
Biscuit merge. Closes #53.
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aleksis/apps/chronos/templates/chronos/plan.html
+40
-53
40 additions, 53 deletions
aleksis/apps/chronos/templates/chronos/plan.html
aleksis/apps/chronos/util.py
+15
-1
15 additions, 1 deletion
aleksis/apps/chronos/util.py
aleksis/apps/chronos/views.py
+6
-9
6 additions, 9 deletions
aleksis/apps/chronos/views.py
with
61 additions
and
63 deletions
aleksis/apps/chronos/templates/chronos/plan.html
+
40
−
53
View file @
e494f43a
...
@@ -9,31 +9,17 @@
...
@@ -9,31 +9,17 @@
{% block content %}
{% block content %}
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
{
%
if
smart
%
}
{
%
if
smart
%
}
var
week
=
{{
selected_week
}};
var
week
=
{{
week
.
week
}};
var
year
=
{{
selected_year
}};
var
year
=
{{
week
.
year
}};
function
goToCalendarWeek
(
cw
,
year
)
{
function
goToCalendarWeek
(
cw
,
year
)
{
window
.
location
.
href
=
"
{% url
"
timetable
_smart_plan
"
type pk %}/
"
+
year
+
"
/
"
+
cw
;
window
.
location
.
href
=
"
{% url
"
timetable
"
type pk %}/
"
+
year
+
"
/
"
+
cw
;
}
}
function
onCalendarWeekChanged
(
where
)
{
function
onCalendarWeekChanged
(
where
)
{
goToCalendarWeek
(
$
(
where
).
val
(),
year
);
goToCalendarWeek
(
$
(
where
).
val
(),
year
);
}
}
function
weekBefore
()
{
if
(
week
>
1
)
{
goToCalendarWeek
(
week
-
1
,
year
)
}
else
{
goToCalendarWeek
(
52
,
year
-
1
)
}
}
function
weekNext
()
{
if
(
week
<
52
)
{
goToCalendarWeek
(
week
+
1
,
year
);
}
else
{
goToCalendarWeek
(
1
,
year
+
1
);
}
}
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
$
(
"
#calendar-week-1
"
).
change
(
function
()
{
$
(
"
#calendar-week-1
"
).
change
(
function
()
{
onCalendarWeekChanged
(
"
#calendar-week-1
"
);
onCalendarWeekChanged
(
"
#calendar-week-1
"
);
...
@@ -44,8 +30,6 @@
...
@@ -44,8 +30,6 @@
$
(
"
#calendar-week-3
"
).
change
(
function
()
{
$
(
"
#calendar-week-3
"
).
change
(
function
()
{
onCalendarWeekChanged
(
"
#calendar-week-3
"
);
onCalendarWeekChanged
(
"
#calendar-week-3
"
);
});
});
$
(
"
#week-before
"
).
click
(
weekBefore
);
$
(
"
#week-next
"
).
click
(
weekNext
);
});
});
{
%
endif
%
}
{
%
endif
%
}
</script>
</script>
...
@@ -92,42 +76,45 @@
...
@@ -92,42 +76,45 @@
{# Week select #}
{# Week select #}
<div
class=
"col s12 m6 right"
>
<div
class=
"col s12 m6 right"
>
<div
class=
"col s2 no-print"
>
<div
class=
"col s2 no-print"
>
<a
class=
"waves-effect waves-teal btn-flat btn-flat-medium right"
id=
"week-before
"
>
<a
class=
"waves-effect waves-teal btn-flat btn-flat-medium right"
href=
"{{ url_prev }}
"
>
<i
class=
"material-icons center"
>
navigate_before
</i>
<i
class=
"material-icons center"
>
navigate_before
</i>
</a>
</a>
</div>
</div>
<div
class=
"input-field col s8 no-margin hide-on-med-and-up"
>
<select
id=
"calendar-week-1"
>
{% with wanted_week=week %}
{% for week in weeks %}
<div
class=
"input-field col s8 no-margin hide-on-med-and-up"
>
<option
value=
"{{ week.calendar_week }}"
{%
if
week.calendar_week =
=
selected_week
%}
<select
id=
"calendar-week-1"
>
selected
{%
endif
%}
>
KW {{ week.calendar_week }}
{% for week in weeks %}
({{ week.first_day|date:"j.n" }}–{{ week.last_day|date:"j.n" }})
<option
value=
"{{ week.week }}"
{%
if
week =
=
wanted_week
%}
</option>
selected
{%
endif
%}
>
KW {{ week.week }} ({{ week.0|date:"j.n" }}–{{ week.6|date:"j.n" }})
{% endfor %}
</option>
</select>
{% endfor %}
</div>
</select>
<div
class=
"input-field col s8 no-margin hide-on-med-and-down"
>
</div>
<select
id=
"calendar-week-2"
>
{% for week in weeks %}
<div
class=
"input-field col s8 no-margin hide-on-med-and-down"
>
<option
value=
"{{ week.calendar_week }}"
{%
if
week.calendar_week =
=
selected_week
%}
<select
id=
"calendar-week-2"
>
selected
{%
endif
%}
>
KW {{ week.calendar_week }}
{% for week in weeks %}
({{ week.first_day|date:"j.n.Y" }}–{{ week.last_day|date:"j.n.Y" }})
<option
value=
"{{ week.week }}"
{%
if
week =
=
wanted_week
%}
</option>
selected
{%
endif
%}
>
KW {{ week.week }} ({{ week.0|date:"j.n.Y" }}–{{ week.6|date:"j.n.Y" }})
{% endfor %}
</option>
</select>
{% endfor %}
</div>
</select>
<div
class=
"input-field col s8 no-margin hide-on-small-and-down hide-on-large-only"
>
</div>
<select
id=
"calendar-week-3"
>
{% for week in weeks %}
<div
class=
"input-field col s8 no-margin hide-on-small-and-down hide-on-large-only"
>
<option
value=
"{{ week.calendar_week }}"
{%
if
week.calendar_week =
=
selected_week
%}
<select
id=
"calendar-week-3"
>
selected
{%
endif
%}
>
KW {{ week.calendar_week }}
{% for week in weeks %}
({{ week.first_day|date:"j.n" }}–{{ week.last_day|date:"j.n.Y" }})
<option
value=
"{{ week.week }}"
{%
if
week =
=
wanted_week
%}
</option>
selected
{%
endif
%}
>
KW {{ week.week }} ({{ week.0|date:"j.n" }}–{{ week.6|date:"j.n.Y" }})
{% endfor %}
</option>
</select>
{% endfor %}
</div>
</select>
</div>
{% endwith %}
<div
class=
"col s2 no-print"
>
<div
class=
"col s2 no-print"
>
<a
class=
"waves-effect waves-teal btn-flat btn-flat-medium left"
id=
"week-
next"
>
<a
class=
"waves-effect waves-teal btn-flat btn-flat-medium left"
href=
"{{ url_
next
}}
"
>
<i
class=
"material-icons center"
>
navigate_next
</i>
<i
class=
"material-icons center"
>
navigate_next
</i>
</a>
</a>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/chronos/util.py
+
15
−
1
View file @
e494f43a
...
@@ -2,7 +2,7 @@ from __future__ import annotations
...
@@ -2,7 +2,7 @@ from __future__ import annotations
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
datetime
import
date
,
datetime
,
timedelta
from
datetime
import
date
,
datetime
,
timedelta
from
typing
import
Optional
,
Sequence
,
Tuple
,
Union
from
typing
import
Optional
,
Sequence
,
Tuple
,
Union
,
List
from
django.apps
import
apps
from
django.apps
import
apps
from
django.db
import
models
from
django.db
import
models
...
@@ -104,3 +104,17 @@ def week_weekday_to_date(week: CalendarWeek, weekday: int) -> date:
...
@@ -104,3 +104,17 @@ def week_weekday_to_date(week: CalendarWeek, weekday: int) -> date:
def
week_period_to_date
(
week
:
Union
[
CalendarWeek
,
int
],
period
)
->
date
:
def
week_period_to_date
(
week
:
Union
[
CalendarWeek
,
int
],
period
)
->
date
:
return
period
.
get_date
(
week
)
return
period
.
get_date
(
week
)
def
get_weeks_for_year
(
year
:
int
)
->
List
[
CalendarWeek
]:
"""
Generates all weeks for one year
"""
weeks
=
[]
# Go for all weeks in year and create week list
current_week
=
CalendarWeek
(
year
=
year
,
week
=
1
)
while
current_week
.
year
==
year
:
weeks
.
append
(
current_week
)
current_week
+=
1
return
weeks
This diff is collapsed.
Click to expand it.
aleksis/apps/chronos/views.py
+
6
−
9
View file @
e494f43a
...
@@ -19,7 +19,7 @@ from aleksis.core.util import messages
...
@@ -19,7 +19,7 @@ from aleksis.core.util import messages
from
.forms
import
LessonSubstitutionForm
from
.forms
import
LessonSubstitutionForm
from
.models
import
LessonPeriod
,
LessonSubstitution
,
TimePeriod
,
Room
from
.models
import
LessonPeriod
,
LessonSubstitution
,
TimePeriod
,
Room
from
.tables
import
LessonsTable
,
SubstitutionsTable
from
.tables
import
LessonsTable
,
SubstitutionsTable
from
.util
import
CalendarWeek
from
.util
import
CalendarWeek
,
get_weeks_for_year
@login_required
@login_required
...
@@ -120,21 +120,18 @@ def timetable(
...
@@ -120,21 +120,18 @@ def timetable(
context
[
"
periods
"
]
=
TimePeriod
.
get_times_dict
()
context
[
"
periods
"
]
=
TimePeriod
.
get_times_dict
()
context
[
"
weekdays
"
]
=
dict
(
TimePeriod
.
WEEKDAY_CHOICES
[
weekday_min
:
weekday_max
+
1
])
context
[
"
weekdays
"
]
=
dict
(
TimePeriod
.
WEEKDAY_CHOICES
[
weekday_min
:
weekday_max
+
1
])
context
[
"
weekdays_short
"
]
=
dict
(
TimePeriod
.
WEEKDAY_CHOICES_SHORT
[
weekday_min
:
weekday_max
+
1
])
context
[
"
weekdays_short
"
]
=
dict
(
TimePeriod
.
WEEKDAY_CHOICES_SHORT
[
weekday_min
:
weekday_max
+
1
])
context
[
"
weeks
"
]
=
get_weeks_for_year
(
year
=
wanted_week
.
year
)
context
[
"
week
"
]
=
wanted_week
context
[
"
week
"
]
=
wanted_week
context
[
"
type
"
]
=
_type
context
[
"
type
"
]
=
_type
context
[
"
pk
"
]
=
pk
context
[
"
pk
"
]
=
pk
context
[
"
el
"
]
=
el
context
[
"
el
"
]
=
el
context
[
"
smart
"
]
=
True
week_prev
=
wanted_week
-
1
week_prev
=
wanted_week
-
1
week_next
=
wanted_week
+
1
week_next
=
wanted_week
+
1
context
[
"
url_prev
"
]
=
"
%s?%s
"
%
(
reverse
(
"
timetable_by_week
"
,
args
=
[
_type
,
pk
,
week_prev
.
year
,
week_prev
.
week
]),
context
[
"
url_prev
"
]
=
reverse
(
"
timetable_by_week
"
,
args
=
[
_type
,
pk
,
week_prev
.
year
,
week_prev
.
week
])
request
.
GET
.
urlencode
(),
context
[
"
url_next
"
]
=
reverse
(
"
timetable_by_week
"
,
args
=
[
_type
,
pk
,
week_next
.
year
,
week_next
.
week
])
)
context
[
"
url_next
"
]
=
"
%s?%s
"
%
(
reverse
(
"
timetable_by_week
"
,
args
=
[
_type
,
pk
,
week_next
.
year
,
week_next
.
week
]),
request
.
GET
.
urlencode
(),
)
return
render
(
request
,
"
chronos/plan.html
"
,
context
)
return
render
(
request
,
"
chronos/plan.html
"
,
context
)
...
...
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