Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9ed462b9
authored
Mar 12, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
request: accept/decline requests
parent
291e2a3c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
3 deletions
+45
-3
circle/request/models.py
+20
-1
circle/request/templates/request/detail.html
+15
-2
circle/request/views.py
+10
-0
No files found.
circle/request/models.py
View file @
9ed462b9
...
...
@@ -55,10 +55,13 @@ class Request(TimeStampedModel):
object_id
=
IntegerField
()
action
=
GenericForeignKey
(
"content_type"
,
"object_id"
)
def
get_absolute_url
(
self
):
return
reverse
(
"request.views.request-detail"
,
kwargs
=
{
'pk'
:
self
.
pk
})
def
get_readable_status
(
self
):
return
self
.
STATUSES
[
self
.
status
]
def
get_icon
(
self
):
def
get_
request_
icon
(
self
):
return
{
'resource'
:
"tasks"
,
'lease'
:
"clock-o"
,
...
...
@@ -73,6 +76,22 @@ class Request(TimeStampedModel):
"DECLINED"
:
"danger"
,
}
.
get
(
self
.
status
)
def
get_status_icon
(
self
):
return
{
"UNSEEN"
:
"eye-slash"
,
"PENDING"
:
"exclamation-triangle"
,
"ACCEPTED"
:
"check"
,
"DECLINED"
:
"times"
,
}
.
get
(
self
.
status
)
def
accept
(
self
):
self
.
status
=
"ACCEPTED"
self
.
save
()
def
decline
(
self
):
self
.
status
=
"DECLINED"
self
.
save
()
class
LeaseType
(
RequestType
):
lease
=
ForeignKey
(
Lease
)
...
...
circle/request/templates/request/detail.html
View file @
9ed462b9
...
...
@@ -15,12 +15,13 @@
{% trans "Back" %}
</a>
<h3
class=
"no-margin"
>
<i
class=
"fa fa-{{ object.get_icon }}"
></i>
<i
class=
"fa fa-{{ object.get_
request_
icon }}"
></i>
{% trans "Request" %}
</h3>
</div>
<div
class=
"panel-body"
>
<div
class=
"label label-{{ object.get_effect }} pull-right"
style=
"font-size: 1.5em; margin-top: 10px;"
>
<i
class=
"fa fa-{{ object.get_status_icon }}"
></i>
{{ object.get_readable_status|upper }}
</div>
<p>
...
...
@@ -79,18 +80,30 @@
{% else %}
hacks!!!
{% endif %}
{% if object.status == "PENDING" %}
<hr
/>
<div
class=
"pull-right"
>
<button
class=
"btn btn-danger"
>
<form
method=
"POST"
style=
"display: inline;"
>
{% csrf_token %}
<button
class=
"btn btn-danger"
type=
"submit"
>
<i
class=
"fa fa-thumbs-down"
></i>
nope
</button>
</form>
<form
method=
"POST"
style=
"display: inline;"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"accept"
value=
"1"
/>
<button
class=
"btn btn-success"
>
<i
class=
"fa fa-thumbs-up"
></i>
yep
</button>
</form>
</div>
{% else %}
close date
{% endif %}
</div>
<!-- .panel-body -->
</div>
</div>
...
...
circle/request/views.py
View file @
9ed462b9
...
...
@@ -46,6 +46,16 @@ class RequestDetail(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
model
=
Request
template_name
=
"request/detail.html"
def
post
(
self
,
*
args
,
**
kwargs
):
accept
=
self
.
request
.
POST
.
get
(
"accept"
)
request
=
self
.
get_object
()
# not self.request!
if
accept
:
request
.
accept
()
else
:
request
.
decline
()
return
redirect
(
request
.
get_absolute_url
())
def
get_context_data
(
self
,
**
kwargs
):
request
=
self
.
object
context
=
super
(
RequestDetail
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
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