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

Add support for scheduled Timecard Notes #1062

Merged
merged 2 commits into from
Apr 23, 2020

Conversation

timoballard
Copy link
Member

Description

Adds support for scheduling Timecard Notes so that they display during a specified date range.

#967

Additional information

  • Adding start/end dates to Timecard Notes is optional.
  • Manually Enabling a Timecard Note will cause it to display even if the scheduled date range is not active.

image

@codecov-io
Copy link

Codecov Report

Merging #1062 into master will increase coverage by 0.09%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1062      +/-   ##
==========================================
+ Coverage   88.37%   88.47%   +0.09%     
==========================================
  Files          41       41              
  Lines        1781     1796      +15     
==========================================
+ Hits         1574     1589      +15     
  Misses        207      207              
Impacted Files Coverage Δ
hours/admin.py 71.21% <0.00%> (ø)
hours/models.py 97.13% <0.00%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9151c59...51bb40c. Read the comment docs.

@@ -314,6 +316,10 @@ class TimecardNoteManager(models.Manager):
def enabled(self):
return super(TimecardNoteManager, self).get_queryset().filter(enabled=True)

def active(self):
now = timezone.now()
return super(TimecardNoteManager, self).get_queryset().filter(Q(enabled=True) | Q(display_period_start__lte=now, display_period_end__gt=now))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this blow up if start and end were left blank?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my testing and understanding, we should be okay here. The field lookups (lt, gt, etc) resolve to false in cases where the value is null

tock/hours/models.py Outdated Show resolved Hide resolved
blank=True,
help_text='The start date for displaying this note. Note: manually enabling will override this setting.'
)
display_period_end = models.DateField(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you wanted to start a note on May 1 and leave it up for an undetermined amount of time? How would that work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right - this implementation doesn't support that, as it requires you to specify either both the start and end date, or neither. It would be pretty straightforward to modify this to support that use case if that's something we want to do.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose one could just put in a far-future end date and call it good, too.

Co-Authored-By: Carter Baxter <32077682+tbaxter-18f@users.noreply.github.com>
@tbaxter-18f tbaxter-18f merged commit f968a4e into master Apr 23, 2020
@Jkrzy Jkrzy linked an issue Apr 23, 2020 that may be closed by this pull request
3 tasks
@Jkrzy
Copy link
Contributor

Jkrzy commented Apr 23, 2020

Thanks @timoballard!

I think we missed a migration here, can you double check and submit a follow-up PR if necessary?

@Jkrzy Jkrzy deleted the tock-967_schedule_timecard_notes branch April 23, 2020 19:22
@timoballard
Copy link
Member Author

Good catch @Jkrzy - I sure did. I overlooked that @tbaxter-18f's suggested change on the help text would imply a migration.

#1067

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Schedule tock timecard notes in advance
4 participants