Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS123-Canteeneo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Willard Torres
CS123-Canteeneo
Commits
590008f8
Commit
590008f8
authored
Nov 08, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge views.py from stash
parent
bbc5e9c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
views.py
canteeneo/views.py
+9
-7
No files found.
canteeneo/views.py
View file @
590008f8
...
...
@@ -54,11 +54,12 @@ def register():
return
render_template
(
'register.html'
,
form
=
form
)
class
StallView
(
MethodView
):
def
valid_stall
(
f
):
@
wraps
(
f
)
def
decorated_function
(
*
args
,
**
kwargs
):
stall_id
=
kwargs
.
get
(
'stall_id'
)
kwargs
.
pop
(
'stall_id'
)
kwargs
[
'stall'
]
=
None
if
stall_id
is
None
:
return
f
(
*
args
,
**
kwargs
)
...
...
@@ -66,13 +67,14 @@ class StallView(MethodView):
if
stall
is
None
or
stall
.
owner
!=
current_user
:
return
redirect
(
url_for
(
'stalls'
))
kwargs
[
'stall'
]
=
stall
return
f
(
*
args
,
**
kwargs
)
return
decorated_function
decorators
=
[
login_required
,
valid_stall
]
def
get
(
self
,
stall
_id
):
if
stall
_id
is
None
:
def
get
(
self
,
stall
):
if
stall
is
None
:
return
render_template
(
'stalls.html'
,
owner
=
current_user
,
stalls
=
current_user
.
stalls
.
all
())
else
:
dishes
=
stall
.
dishes
.
all
()
...
...
@@ -90,7 +92,7 @@ class StallView(MethodView):
flash_form_errors
(
form
)
return
redirect
(
url_for
(
'new_stall'
))
def
put
(
self
,
stall
_id
):
def
put
(
self
,
stall
):
form
=
StallRegisterForm
()
form
.
location
.
choices
=
[(
loc
.
id
,
loc
.
name
)
for
loc
in
Location
.
query
.
all
()]
if
form
.
validate
(
editing
=
True
):
...
...
@@ -101,12 +103,12 @@ class StallView(MethodView):
return
redirect
(
url_for
(
'stalls'
))
else
:
flash_form_errors
(
form
)
return
redirect
(
url_for
(
'edit_stall'
,
values
=
[(
'stall_id'
,
stall
_
id
)]))
return
redirect
(
url_for
(
'edit_stall'
,
values
=
[(
'stall_id'
,
stall
.
id
)]))
def
delete
(
self
,
stall
_id
):
def
delete
(
self
,
stall
):
db
.
session
.
delete
(
stall
)
db
.
session
.
commit
()
return
redirect
(
url_for
(
'stalls'
))
return
redirect
(
url_for
(
'stalls'
))
stalls
=
StallView
.
as_view
(
'stalls'
)
stall
=
StallView
.
as_view
(
'stall'
)
...
...
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