-
Notifications
You must be signed in to change notification settings - Fork 4.2k
AA-34: Add UserCalendar Model #23147
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
Conversation
|
jenkins run bokchoy |
openedx/features/calendar/models.py
Outdated
| from opaque_keys.edx.django.models import CourseKeyField | ||
|
|
||
|
|
||
| class UserCalendar(models.Model): |
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.
Should this have a uniqueness constraint of (user, course_key)?
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.
I think so, yes. Otherwise a user could have multiple calendar configs for the same course.
openedx/features/calendar/models.py
Outdated
| from opaque_keys.edx.django.models import CourseKeyField | ||
|
|
||
|
|
||
| class UserCalendar(models.Model): |
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.
I think so, yes. Otherwise a user could have multiple calendar configs for the same course.
openedx/features/calendar/models.py
Outdated
| .. no_pii: | ||
| """ | ||
| user = models.ForeignKey(User, db_index=True, on_delete=models.CASCADE) | ||
| course_key = CourseKeyField(max_length=255, db_index=True) |
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.
Ugh. Do we still do this, and avoid foreign keys?
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 was the pattern I found throughout the code. Not sure what we would want to foreign key against anyway
openedx/features/calendar/models.py
Outdated
| """ | ||
| user = models.ForeignKey(User, db_index=True, on_delete=models.CASCADE) | ||
| course_key = CourseKeyField(max_length=255, db_index=True) | ||
| enabled = models.BooleanField(default=False) |
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.
Maybe worth adding a utility method like is_enabled_for_course(user, course) that does a get with a default value of False if it doesn't exist in the model?
openedx/features/calendar/models.py
Outdated
| from opaque_keys.edx.django.models import CourseKeyField | ||
|
|
||
|
|
||
| class UserCalendar(models.Model): |
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.
Should this be named UserCalendarConfig or something? Rather than it being the object itself?
Or even, UserCalendarSyncConfig, because this is toggling the sync/email functionality. Or if not that, maybe rename enabled to sync_enabled or something.
49f3f44 to
4d883b3
Compare
mikix
left a comment
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.
Nice
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 is 2 lookups, yeah? Try/except might get you to just one.
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.
You got it dude
87155b9 to
a3093e2
Compare
a3093e2 to
bb1981d
Compare
|
Your PR has finished running tests. There were no failures. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
No description provided.