Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
75315d77
Commit
75315d77
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
in kit request view there is a button that can send emails
parent
42698332
No related branches found
No related tags found
1 merge request
!47
Resolve "Email to technician"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
smash/web/templates/equipment_and_rooms/kit_requests.html
+2
-2
2 additions, 2 deletions
smash/web/templates/equipment_and_rooms/kit_requests.html
smash/web/views/kit.py
+41
-2
41 additions, 2 deletions
smash/web/views/kit.py
with
43 additions
and
4 deletions
smash/web/templates/equipment_and_rooms/kit_requests.html
+
2
−
2
View file @
75315d77
...
...
@@ -88,10 +88,10 @@
<div
class=
"col-sm-12"
>
{% if end_date == None %}
<a
href=
"{% url 'web.views.kit_requests_send_mail' start_date|date:"
Y-m-d
"
%}"
class=
"btn btn-block btn-default"
>
S
how
email
content
</a>
class=
"btn btn-block btn-default"
>
S
end
email
</a>
{% else %}
<a
href=
"{% url 'web.views.kit_requests_send_mail' start_date|date:"
Y-m-d
"
end_date
|
date:
"
Y-m-d
"
%}"
class=
"btn btn-block btn-default"
>
S
how
email
content
</a>
class=
"btn btn-block btn-default"
>
S
end
email
</a>
{% endif %}
</div>
</div>
<!-- /.box-footer -->
...
...
This diff is collapsed.
Click to expand it.
smash/web/views/kit.py
+
41
−
2
View file @
75315d77
# coding=utf-8
import
datetime
from
django.contrib
import
messages
from
django.utils.dateparse
import
parse_datetime
from
notifications
import
get_filter_locations
,
get_today_midnight_date
from
web.models
import
ConfigurationItem
from
web.models.constants
import
KIT_RECIPIENT_EMAIL_CONFIGURATION_TYPE
from
.
import
wrap_response
from
..email
import
EmailSender
from
..forms
import
KitRequestForm
from
..models
import
AppointmentType
,
Appointment
...
...
@@ -16,8 +20,12 @@ def get_kit_requests(user, start_date=None, end_date=None):
else
:
if
isinstance
(
start_date
,
str
):
start_date
=
parse_datetime
(
start_date
)
if
isinstance
(
start_date
,
unicode
):
start_date
=
datetime
.
datetime
.
strptime
(
start_date
,
'
%Y-%m-%d
'
)
if
(
end_date
is
not
None
)
and
(
isinstance
(
end_date
,
str
)):
end_date
=
parse_datetime
(
end_date
)
if
(
end_date
is
not
None
)
and
(
isinstance
(
end_date
,
unicode
)):
end_date
=
datetime
.
datetime
.
strptime
(
end_date
,
'
%Y-%m-%d
'
)
appointment_types
=
AppointmentType
.
objects
.
filter
(
required_equipment__disposable
=
True
)
...
...
@@ -59,5 +67,36 @@ def kit_requests(request):
def
kit_requests_send_mail
(
request
,
start_date
,
end_date
=
None
):
return
wrap_response
(
request
,
'
equipment_and_rooms/kit_requests_send_mail.html
'
,
get_kit_requests_data
(
request
,
start_date
,
end_date
))
data
=
get_kit_requests_data
(
request
,
start_date
,
end_date
)
end_date_str
=
"
end of time
"
if
end_date
is
not
None
:
end_date_str
=
data
[
"
end_date
"
].
strftime
(
'
%Y-%m-%d
'
)
title
=
"
Kits required between
"
+
data
[
"
start_date
"
].
strftime
(
'
%Y-%m-%d
'
)
+
"
and
"
+
end_date_str
email_body
=
"
<h1>
"
+
title
+
"
</h1>
"
email_body
+=
"
<table><thead><tr><th>Date</th><th>Kits</th><th>Location</th><th>Person responsible</th></tr></thead>
"
email_body
+=
"
<tbody>
"
for
appointment
in
data
[
"
appointments
"
]:
email_body
+=
"
<tr>
"
email_body
+=
"
<td>
"
+
appointment
.
datetime_when
.
strftime
(
'
%Y-%m-%d %H:%M
'
)
+
"
</td>
"
email_body
+=
"
<td>
"
for
type
in
appointment
.
appointment_types
.
all
():
for
item
in
type
.
required_equipment
.
all
():
if
item
.
disposable
:
email_body
+=
item
.
name
+
"
,
"
email_body
+=
"
</td>
"
email_body
+=
"
<td>
"
+
str
(
appointment
.
location
)
+
"
</td>
"
email_body
+=
"
<td>
"
+
str
(
appointment
.
worker_assigned
)
+
"
</td>
"
email_body
+=
"
</tr>
"
email_body
+=
"
</tbody></table>
"
recipients
=
ConfigurationItem
.
objects
.
get
(
type
=
KIT_RECIPIENT_EMAIL_CONFIGURATION_TYPE
).
value
sender
=
request
.
user
.
email
cc_recipients
=
[]
if
sender
is
not
None
:
cc_recipients
.
append
(
sender
)
try
:
EmailSender
().
send_email
(
title
,
email_body
,
recipients
,
cc_recipients
)
messages
.
add_message
(
request
,
messages
.
SUCCESS
,
'
Mail sent
'
)
except
:
messages
.
add_message
(
request
,
messages
.
ERROR
,
'
There was problem with sending email
'
)
return
wrap_response
(
request
,
'
equipment_and_rooms/kit_requests.html
'
,
get_kit_requests_data
(
request
))
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