Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor 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-Core
Commits
eb0b2287
Commit
eb0b2287
authored
6 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Add current plan
parent
22dc8ef5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!86
Merge school-apps
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
schoolapps/helper.py
+1
-1
1 addition, 1 deletion
schoolapps/helper.py
schoolapps/mealplan/templates/menu/index.html
+2
-0
2 additions, 0 deletions
schoolapps/mealplan/templates/menu/index.html
schoolapps/mealplan/views.py
+15
-10
15 additions, 10 deletions
schoolapps/mealplan/views.py
with
18 additions
and
11 deletions
schoolapps/helper.py
+
1
−
1
View file @
eb0b2287
...
...
@@ -6,7 +6,7 @@ from django.template.loader_tags import register
def
path_and_rename
(
instance
,
filename
):
upload_to
=
'
menus
'
ext
=
filename
.
split
(
'
.
'
)[
-
1
]
ext
=
filename
.
split
(
'
.
'
)[
-
1
]
.
lower
()
# get filename
if
instance
.
pk
:
filename
=
'
{}.{}
'
.
format
(
instance
.
pk
,
ext
)
...
...
This diff is collapsed.
Click to expand it.
schoolapps/mealplan/templates/menu/index.html
+
2
−
0
View file @
eb0b2287
...
...
@@ -13,6 +13,8 @@
</script>
<a
class=
"waves-effect waves-light btn green"
href=
"{% url "
menu_upload
"
%}"
><i
class=
"material-icons left"
>
add
</i>
Neuen Speiseplan hochladen
</a>
<a
class=
"waves-effect waves-light btn"
href=
"{% url "
menu_show_current
"
%}"
><i
class=
"material-icons left"
>
picture_as_pdf
</i>
Aktuellen Speiseplan anzeigen
</a>
<h5>
Übersicht der hochgeladenen Speisepläne
</h5>
<ul
class=
"collection"
>
{% for menu in menus %}
...
...
This diff is collapsed.
Click to expand it.
schoolapps/mealplan/views.py
+
15
−
10
View file @
eb0b2287
...
...
@@ -30,36 +30,41 @@ def index(request, msg=None):
def
return_pdf
(
filename
):
print
(
filename
)
# Read and response PDF
"""
Read and response a PDF file
"""
file
=
open
(
filename
,
"
rb
"
)
return
FileResponse
(
file
,
content_type
=
"
application/pdf
"
)
def
return_default_pdf
():
"""
Response the default PDF
"""
return
return_pdf
(
os
.
path
.
join
(
"
mealplan
"
,
"
default.pdf
"
))
def
show_current
(
request
):
# Get current date with year and calendar week
current_date
=
timezone
.
datetime
.
now
()
year
,
calendar_week
=
current_date
.
isocalendar
()[:
2
]
# print(calendar_week)
#
current_date += datetime.timedelta(days=4)
#
Calculate the number of days to next friday
days_to_add
=
5
-
current_date
.
isoweekday
()
# print(days_to_add)
if
days_to_add
<
0
:
days_to_add
=
days_to_add
+
7
# print(days_to_add)
# Create datetime with next friday and time 14:10
friday
=
current_date
+
datetime
.
timedelta
(
days
=
days_to_add
)
# print(friday)
friday_14_10
=
timezone
.
datetime
(
friday
.
year
,
friday
.
month
,
friday
.
day
,
14
,
10
)
# print(friday_14_10)
# Check whether to show the plan of the next week or the current week
if
current_date
>
friday_14_10
:
calendar_week
+=
1
print
(
calendar_week
)
# Look for matching PDF in DB
try
:
obj
=
MealPlan
.
objects
.
get
(
year
=
year
,
calendar_week
=
calendar_week
)
print
(
os
.
path
.
join
(
"
media
"
,
str
(
obj
.
pdf
)))
return
return_pdf
(
os
.
path
.
join
(
"
media
"
,
str
(
obj
.
pdf
)))
# Or show the default PDF
except
MealPlan
.
DoesNotExist
:
return
return_default_pdf
()
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