Skip to content

Conversation

@Dillon-Dumesnil
Copy link
Contributor

No description provided.

@Dillon-Dumesnil
Copy link
Contributor Author

jenkins run bokchoy

from opaque_keys.edx.django.models import CourseKeyField


class UserCalendar(models.Model):
Copy link
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
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.

from opaque_keys.edx.django.models import CourseKeyField


class UserCalendar(models.Model):
Copy link
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.

.. no_pii:
"""
user = models.ForeignKey(User, db_index=True, on_delete=models.CASCADE)
course_key = CourseKeyField(max_length=255, db_index=True)
Copy link
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
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

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

from opaque_keys.edx.django.models import CourseKeyField


class UserCalendar(models.Model):
Copy link
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
Copy link
Contributor

@mikix mikix left a comment

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

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
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
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.

5 participants