Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/OP-1339: Fix Date Closed Calculation #354

Merged
merged 2 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,10 @@ def communication_method_type(self):
return response_type.LETTER if response_type.LETTER in [cm.method_type for cm in
communication_methods] else response_type.EMAIL

@property
def event_timestamp(self):
return Events.query.filter_by(response_id=self.id).one().timestamp

def make_public(self):
self.privacy = response_privacy.RELEASE_AND_PUBLIC
self.release_date = calendar.addbusdays(datetime.utcnow(), RELEASE_PUBLIC_DAYS)
Expand Down
4 changes: 2 additions & 2 deletions app/request/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ def get_request_responses():

current_request = Requests.query.filter_by(id=flask_request.args['request_id']).one()

responses = Responses.query.filter(
responses = Responses.query.join(Events, Responses.id == Events.response_id).filter(
Responses.request_id == current_request.id,
~Responses.id.in_([cm.method_id for cm in CommunicationMethods.query.all()]),
Responses.type != response_type.EMAIL,
Responses.deleted == False
).order_by(
desc(Responses.date_modified)
desc(Events.timestamp)
).all()[start: start + RESPONSES_INCREMENT]

template_path = 'request/responses/'
Expand Down
46 changes: 34 additions & 12 deletions app/response/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,23 @@ def add_denial(request_id, reason_ids, content, method, letter_template_id):
request_id,
es_update=False
)
response = Determinations(
request_id,
RELEASE_AND_PUBLIC,
determination_type.DENIAL,
format_determination_reasons(reason_ids)
)
if not calendar.isbusday(datetime.utcnow()) or datetime.utcnow().date() < request.date_submitted.date():
# push the denial date to the next business day if it is a weekend/holiday
# or if it is before the date submitted
response = Determinations(
request_id,
RELEASE_AND_PUBLIC,
determination_type.DENIAL,
format_determination_reasons(reason_ids),
date_modified=get_next_business_day()
)
else:
response = Determinations(
request_id,
RELEASE_AND_PUBLIC,
determination_type.DENIAL,
format_determination_reasons(reason_ids)
)
if method == 'letter':
response.reason = 'A letter will be mailed to the requester.'
create_object(response)
Expand Down Expand Up @@ -367,12 +378,23 @@ def add_closing(request_id, reason_ids, content, method, letter_template_id):
request_id,
es_update=False
)
response = Determinations(
request_id,
RELEASE_AND_PUBLIC,
determination_type.CLOSING,
format_determination_reasons(reason_ids)
)
if not calendar.isbusday(datetime.utcnow()) or datetime.utcnow().date() < current_request.date_submitted.date():
# push the closing date to the next business day if it is a weekend/holiday
# or if it is before the date submitted
response = Determinations(
request_id,
RELEASE_AND_PUBLIC,
determination_type.CLOSING,
format_determination_reasons(reason_ids),
date_modified=get_next_business_day()
)
else:
response = Determinations(
request_id,
RELEASE_AND_PUBLIC,
determination_type.CLOSING,
format_determination_reasons(reason_ids)
)
if method == 'letter':
response.reason = 'A letter will be mailed to the requester.'
create_object(response)
Expand Down
6 changes: 3 additions & 3 deletions app/templates/request/responses/row.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@

{% if current_user.is_agency %}
<div class="col-md-5 text-right">
{{ moment(response.date_modified).format('dddd, MM/DD/YYYY [at] h:mm A') }}
{{ moment(response.event_timestamp).format('dddd, MM/DD/YYYY [at] h:mm A') }}
</div>
<div class="row">
<div class="col-md-10 metadata-preview">
{% if show_preview and response.preview is not none %}
{{ response.preview | safe}}
{{ response.preview | safe }}
{% endif %}
</div>
</div>
{% else %}
<div class="col-md-6 metadata-preview">
{% if show_preview and response.preview is not none %}
{{ response.preview | safe}}
{{ response.preview | safe }}
{% endif %}
</div>
<div class="col-md-3">
Expand Down