-
Notifications
You must be signed in to change notification settings - Fork 38
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
Adding date_start and date_end to Course model and making other backend adjustments #652
Adding date_start and date_end to Course model and making other backend adjustments #652
Conversation
…ng out Course appearance in admin
FYI, in addition to the changes @zqian requested, I simplified the verbose names for dates on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates!
dashboard/models.py
Outdated
end = self.date_end | ||
else: | ||
end = self.term.get_correct_date_end() | ||
return start, end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A namedtuple would make this easier to read and work with. It's an 'anti-pattern' to use an ambiguous index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense to me. See latest commit.
dashboard/views.py
Outdated
return df['date_start'].iloc[0] | ||
def get_course_date_start(course_id): | ||
logger.info(get_course_date_start.__name__) | ||
course_date_start = Course.objects.get(id=course_id).get_course_date_range()[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using namedtuple (above) would make this get_course_date_range().date_start
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See latest commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good @zqian's comments looks good. I'd fix the one issue I mentioned. I'm not sure if we've been using this practice in the past but this one is better.
@ssciolla Looks good, this was a really good Pycon session where I first saw namedtuple and how cool it was if you ever have time to watch! https://www.youtube.com/watch?v=wf-BqAjZb8M |
Maybe dev should have a list of "favorite videos to watch when you got time" somewhere... |
* "the welcome page" snuck in again somehow (#627) * Extracted the snackbar component so it can be used anywhere where there is user setting (#626) * Fixes #619 resource_type is marked as primary key but doesn't need to be (#620) * #579 assignments now scrolls to current week row (#632) * #579 assignments now scrolls to current week row * #579 getting the local time from the timezone object instead * #631 adding default resources property (#633) * #631 adding default resources property * Update URL * Fixes #533 Files accessed view keeps showing loading spinner (#636) * Fixes #634 Fix spelling of variable roundToOneDecimcal (#635) * Resolving issue 628: checkbox color, grade toggling, admin handling (#640) * Fix Resources view issues (#638) * Fix typo (#649) Renamed `show_files_accessed` to `show_resources_accessed` in a couple places * Changes to README and new CONTRIBUTING doc (#606) * README intro written * Added contributing guide * Reorganized readme * Added a note about technology used * Updated headings * Moved contributing guide to bottom * Small change to CONTRIBUTING * Added link to google drive * Small changes to contributing * expanded technology overview for front end * Email field required for creating user via command line * Adding Backend tech stack * Fixes #644 - Name for courses in urls.py wrong (#645) * xaxis is reflects based on % from data than always showing 0-100 (#654) * Adding date_start and date_end to Course model and making other backend adjustments (#652) * Modifying Course, AcademicTerms models; updating views to use course dates * Re-adding db_constraint to term; adding far-out year handling; fleshing out Course appearance in admin * Modifying verbose names; simplifying query; adjusting logger * Implementing namedtuple for DateRange * #643 adding a check for no students in a particular grade range (#655) * Fixes #650 Update support for CSP headers (#656) * Fixes #650 Update CSP headers * Adding XFrameOptions as alternative * Fixes #653 map a secrets directory for easier addition of secrets (#657) * Fixes #653 map a secrets directory for easier addition of secrets * Updating documentation * Fixes based on Andrew's code review * Fix LTI (#659) Noticed that `rules.permissions.ObjectPermissionBackend` was interfering with the LTI login (ObjectPermissionBackend doesn't have a get_user function) since it is the first auth method listed after the permissions update. Switching to explicitly using the `django.contrib.auth.backends.ModelBackend` backend (and making sure its a backend available if lti is enabled)
* master: Fix LTI (#659) Fixes #653 map a secrets directory for easier addition of secrets (#657) Fixes #650 Update support for CSP headers (#656) #643 adding a check for no students in a particular grade range (#655) Adding date_start and date_end to Course model and making other backend adjustments (#652) xaxis is reflects based on % from data than always showing 0-100 (#654) Fixes #644 - Name for courses in urls.py wrong (#645) Changes to README and new CONTRIBUTING doc (#606) Fix typo (#649) Fix Resources view issues (#638) Resolving issue 628: checkbox color, grade toggling, admin handling (#640) # Conflicts: # README.md # dashboard/models.py
This PR makes modifications to
models.py
,views.py
, andadmin.py
and creates a new migration, in an effort to resolve Issue 343. The changes are summarized below:Two new fields --
date_start
anddate_end
-- were added to theCourse
model in order to allow admins to manually enter a date range for a course. A helper methodget_course_date_range
was also added to the model so that if course dates are not provided, the dates associated with the relatedAcademicTerm
are accessed. Additionally, theterm_id
field was changed toterm
to reflect that the field holds theAcademicTerms
object instance, not an integer or string. Theid
field was also madeeditable
, possibly eliminating some unwanted behavior; see Issue 613.The
objects
field of theAcademicTerms
model was removed, as were theManager
andQuerySet
helper classes for the model, as their functionality had been replaced with the changes toCourse
and they were no longer being used. A helper methodget_correct_date_end
was also added to correct far-out end years (usually ten years into the future) to the same year as the start date.A new migration file,
0010_auto_20190812_0924.py
, was added to reflect the changes outlined in 1. and 2. (The original PR included another migration file,0010_auto_20190809_1625.py
.)Changes were made to
views.py
to rely on theget_course_date_range
method for determining the course's beginning and end dates. These modifications mean that course dates provided in the admin interface will affect the number of weeks that show up in the front end, for instance, through the Resources Accessed view.Some additional fields were provided in the
list_display
field of theCourseAdmin
class inadmin.py
to make the list appearance of courses in the admin interface more informative.