Skip to content

Commit

Permalink
Merge pull request #230 from CityOfNewYork/hotfix/OP-1303
Browse files Browse the repository at this point in the history
hotfix/OP-1303: Add Link to Files Submitted with Request
  • Loading branch information
johnyu95 authored Oct 18, 2017
2 parents ee62455 + c9aca34 commit 92be7bf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
17 changes: 15 additions & 2 deletions app/request/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
ACKNOWLEDGMENT_DAYS_DUE,
REQUESTER_ACKNOWLEDGMENT_DAYS_DUE,
user_type_request,
response_type
)
from app.constants.response_privacy import (
RELEASE_AND_PRIVATE,
Expand Down Expand Up @@ -54,9 +55,13 @@
UserRequests,
Roles,
Files,
ResponseTokens
ResponseTokens,
Responses,
)
from app.response.utils import (
safely_send_and_add_email,
get_file_links
)
from app.response.utils import safely_send_and_add_email
from app.upload.constants import upload_status
from app.upload.utils import (
is_valid_file_type,
Expand Down Expand Up @@ -429,6 +434,13 @@ def send_confirmation_email(request, agency, user):
requester_email = user.email
address = user.mailing_address

# gets the file link, if a file was provided.
file_response = request.responses.filter(Responses.type == response_type.FILE).one_or_none()
release_public, release_private, private = ([] for i in range(3))
if file_response is not None:
get_file_links(file_response, release_public, release_private, private)
file_link = release_private[0] if len(release_private) > 0 else None

# generates the view request page URL for this request
if agency.is_active:
page = urljoin(flask_request.host_url, url_for('request.view', request_id=request.id))
Expand All @@ -446,6 +458,7 @@ def send_confirmation_email(request, agency, user):
agency_default_email=agency_default_email,
user=user,
address=address,
file_link=file_link,
page=page)

try:
Expand Down
3 changes: 2 additions & 1 deletion app/request/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from app.constants import (
request_status,
permission
permission,
)
from app.lib.date_utils import (
DEFAULT_YEARS_HOLIDAY_LIST,
Expand Down Expand Up @@ -148,6 +148,7 @@ def new():

current_request = Requests.query.filter_by(id=request_id).first()
requester = current_request.requester

send_confirmation_email(request=current_request, agency=current_request.agency, user=requester)

if current_request.agency.is_active:
Expand Down
6 changes: 5 additions & 1 deletion app/templates/email_templates/email_confirmation.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
Request Description: {{ current_request.description }}
<br/>
<br/>

{% if file %}
Attached File: {{ file['title'] }}: <a href="{{ file['link'] }}">{{ file['filename'] }}
<br/>
<br/>
{% endif %}
<p style="text-decoration: underline">Requester's Contact Information</p>
<div class="row-fluid hide" id="requester_info">
<div>
Expand Down
6 changes: 5 additions & 1 deletion app/templates/email_templates/email_not_onboarded.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
Request Description: {{ current_request.description }}
<br/>
<br/>

{% if file %}
Attached File: {{ file['title'] }}: <a href="{{ file['link'] }}">{{ file['filename'] }}
<br/>
<br/>
{% endif %}
<p style="text-decoration: underline">Requester's Contact Information</p>
<div class="row-fluid hide" id="requester_info">
<div>
Expand Down

0 comments on commit 92be7bf

Please sign in to comment.