Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
13 deletions
+55
-13
circle/request/models.py
+20
-1
circle/request/templates/request/detail.html
+25
-12
circle/request/views.py
+10
-0
No files found.
circle/request/models.py
View file @
9ed462b9
...
@@ -55,10 +55,13 @@ class Request(TimeStampedModel):
...
@@ -55,10 +55,13 @@ class Request(TimeStampedModel):
object_id
=
IntegerField
()
object_id
=
IntegerField
()
action
=
GenericForeignKey
(
"content_type"
,
"object_id"
)
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
):
def
get_readable_status
(
self
):
return
self
.
STATUSES
[
self
.
status
]
return
self
.
STATUSES
[
self
.
status
]
def
get_icon
(
self
):
def
get_
request_
icon
(
self
):
return
{
return
{
'resource'
:
"tasks"
,
'resource'
:
"tasks"
,
'lease'
:
"clock-o"
,
'lease'
:
"clock-o"
,
...
@@ -73,6 +76,22 @@ class Request(TimeStampedModel):
...
@@ -73,6 +76,22 @@ class Request(TimeStampedModel):
"DECLINED"
:
"danger"
,
"DECLINED"
:
"danger"
,
}
.
get
(
self
.
status
)
}
.
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
):
class
LeaseType
(
RequestType
):
lease
=
ForeignKey
(
Lease
)
lease
=
ForeignKey
(
Lease
)
...
...
circle/request/templates/request/detail.html
View file @
9ed462b9
...
@@ -15,12 +15,13 @@
...
@@ -15,12 +15,13 @@
{% trans "Back" %}
{% trans "Back" %}
</a>
</a>
<h3
class=
"no-margin"
>
<h3
class=
"no-margin"
>
<i
class=
"fa fa-{{ object.get_icon }}"
></i>
<i
class=
"fa fa-{{ object.get_
request_
icon }}"
></i>
{% trans "Request" %}
{% trans "Request" %}
</h3>
</h3>
</div>
</div>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
<div
class=
"label label-{{ object.get_effect }} pull-right"
style=
"font-size: 1.5em; margin-top: 10px;"
>
<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 }}
{{ object.get_readable_status|upper }}
</div>
</div>
<p>
<p>
...
@@ -79,18 +80,30 @@
...
@@ -79,18 +80,30 @@
{% else %}
{% else %}
hacks!!!
hacks!!!
{% endif %}
{% endif %}
<hr
/>
<div
class=
"pull-right"
>
{% if object.status == "PENDING" %}
<button
class=
"btn btn-danger"
>
<hr
/>
<i
class=
"fa fa-thumbs-down"
></i>
nope
<div
class=
"pull-right"
>
</button>
<form
method=
"POST"
style=
"display: inline;"
>
<button
class=
"btn btn-success"
>
{% csrf_token %}
<i
class=
"fa fa-thumbs-up"
></i>
<button
class=
"btn btn-danger"
type=
"submit"
>
yep
<i
class=
"fa fa-thumbs-down"
></i>
</button>
nope
</div>
</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>
<!-- .panel-body -->
</div>
</div>
</div>
</div>
...
...
circle/request/views.py
View file @
9ed462b9
...
@@ -46,6 +46,16 @@ class RequestDetail(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
...
@@ -46,6 +46,16 @@ class RequestDetail(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
model
=
Request
model
=
Request
template_name
=
"request/detail.html"
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
):
def
get_context_data
(
self
,
**
kwargs
):
request
=
self
.
object
request
=
self
.
object
context
=
super
(
RequestDetail
,
self
)
.
get_context_data
(
**
kwargs
)
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