Skip to content

AA-34: Add UserCalendar Model - #23147

Merged
Dillon-Dumesnil merged 1 commit into
masterfrom
ddumesnil/create-calendar-model-AA-34
Feb 21, 2020
Merged

AA-34: Add UserCalendar Model#23147
Dillon-Dumesnil merged 1 commit into
masterfrom
ddumesnil/create-calendar-model-AA-34

Conversation

@Dillon-Dumesnil

Copy link
Copy Markdown
Contributor

No description provided.

@Dillon-Dumesnil

Copy link
Copy Markdown
Contributor Author

jenkins run bokchoy

Comment thread openedx/features/calendar/models.py Outdated
from opaque_keys.edx.django.models import CourseKeyField


class UserCalendar(models.Model):

Copy link
Copy Markdown
Contributor Author

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)?

Copy link
Copy Markdown
Contributor

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.

Comment thread openedx/features/calendar/models.py Outdated
from opaque_keys.edx.django.models import CourseKeyField


class UserCalendar(models.Model):

Copy link
Copy Markdown
Contributor

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.

Comment thread 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)

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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

Comment thread 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)

Copy link
Copy Markdown
Contributor

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?

Comment thread openedx/features/calendar/models.py Outdated
from opaque_keys.edx.django.models import CourseKeyField


class UserCalendar(models.Model):

Copy link
Copy Markdown
Contributor

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.

@Dillon-Dumesnil
Dillon-Dumesnil force-pushed the ddumesnil/create-calendar-model-AA-34 branch 3 times, most recently from 49f3f44 to 4d883b3 Compare February 20, 2020 20:21

@mikix mikix left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice

Comment on lines 38 to 40

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You got it dude

@Dillon-Dumesnil
Dillon-Dumesnil force-pushed the ddumesnil/create-calendar-model-AA-34 branch 2 times, most recently from 87155b9 to a3093e2 Compare February 21, 2020 18:32
@Dillon-Dumesnil
Dillon-Dumesnil force-pushed the ddumesnil/create-calendar-model-AA-34 branch from a3093e2 to bb1981d Compare February 21, 2020 19:21
@edx-status-bot

Copy link
Copy Markdown

Your PR has finished running tests. There were no failures.

@Dillon-Dumesnil
Dillon-Dumesnil merged commit 5ea4d8f into master Feb 21, 2020
@Dillon-Dumesnil
Dillon-Dumesnil deleted the ddumesnil/create-calendar-model-AA-34 branch February 21, 2020 20:01
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

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.

4 participants