Skip to content

Instantly share code, notes, and snippets.

@rfadams
Created August 18, 2015 18:58
Show Gist options
  • Save rfadams/c2f78a1bc28f3b63dded to your computer and use it in GitHub Desktop.
Save rfadams/c2f78a1bc28f3b63dded to your computer and use it in GitHub Desktop.
created by github.com/tr3buchet/gister

Company Trial Start / End Dates - Phase 1

We need to know if a company is in a "trial" status. There will be 2 phases to this project.

Phase 1 will construct the fields. Phase 2 will be to create the cron job that will automatically check for expired trial periods and mark the "trial_status" boolean to false.

Backend

On the Company model, create:

  • trial_status = BooleanField
  • trial_start = DateField(default=date.today()
  • trial_end = DateField(default=date.today() + relativedelta(months=1))

Expose those fields through the api's that feed the front-end Company Profile.

Form Validation

The Company Profile already has error handling done through the backend and those errors will be exposed on the front-end (although this is currently a ticket in progress).

For now, we should check that:

  • trial_start and trial_end are both dates either today or in the future.
  • trial_end should be later than trial_start

Front-End

Add fields as shown here: http://note.io/1ANSnCv

The date fields can stay active even if the trial_status is unchecked, they do not need to enable / disable depending on the trial_status.

The trial_end field should adjust to +1 month of whatever date is set in trial_start onchange of trial_start. So if trial_start is modified, update trial_end, evne if it has been previously set (just make sure the UI properly updates onchange).

There is a calendar widget here: http://note.io/1cBgzfI. Please use that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment