Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
974f2369
Commit
974f2369
authored
Oct 17, 2015
by
Daniel W Bond
Browse files
implemented deleteview
parent
4a981578
Changes
1
Hide whitespace changes
Inline
Side-by-side
roomlist/accounts/views.py
View file @
974f2369
...
...
@@ -105,7 +105,13 @@ class DetailStudent(LoginRequiredMixin, DetailView):
flags
=
Confirmation
.
objects
.
filter
(
confirmer
=
requesting_student
,
student
=
self
.
get_object
()).
count
()
print
flags
,
bool
(
flags
)
if
flags
:
try
:
my_flag
=
Confirmation
.
objects
.
get
(
confirmer
=
requesting_student
,
student
=
self
.
get_object
())
except
Exception
as
e
:
print
"Students are not supposed to be able to make more than one flag per student."
print
e
def
onFloor
():
floor_status
=
False
...
...
@@ -136,6 +142,8 @@ class DetailStudent(LoginRequiredMixin, DetailView):
context
[
'shares'
]
=
shares
()
context
[
'same_floor'
]
=
same_floor
context
[
'has_flagged'
]
=
bool
(
flags
)
if
flags
:
context
[
'my_flag'
]
=
my_flag
return
context
...
...
@@ -540,18 +548,19 @@ class CreateConfirmation(LoginRequiredMixin, CreateView):
class
DeleteConfirmation
(
LoginRequiredMixin
,
DeleteView
):
model
=
Confirmation
context_object_name
=
None
fields
=
None
template_name
=
None
template_name
=
'delete_confirmation.html'
login_url
=
'login'
def
get
(
self
):
return
True
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
requester
=
Student
.
objects
.
get
(
user
=
self
.
request
.
user
)
confirmer
=
self
.
get_object
().
confirmer
def
form_valid
(
self
):
return
True
if
not
(
requester
==
confirmer
):
return
HttpResponseForbidden
()
else
:
return
super
(
DeleteConfirmation
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
def
get_success_url
(
self
):
return
reverse
(
'detail_student'
,
kwargs
=
{
'slug'
:
self
.
request
.
user
.
username
})
kwargs
=
{
'slug'
:
self
.
object
.
student
.
slug
})
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