-
Notifications
You must be signed in to change notification settings - Fork 7
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
Faster Way To Add Late Starts #285
Conversation
No need to have the organization field as that will always be set to school, what you can do though is check if school exists and if not then create it |
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.
Lastly, how would you access this form without direct url
core/models/course.py
Outdated
@@ -266,7 +266,7 @@ def get_events(cls, user=None): | |||
return events | |||
|
|||
def clean(self): | |||
if self.start_date > self.end_date: | |||
if self.start_date != None and self.end_date != None and self.start_date > self.end_date: |
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.
Reason for changing this?
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.
Was mildly annoying me when testing some things. This change can 100% be dropped.
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.
Well there should never be an event without a start/end date set. that is enforced both on the model both by the super().clean() and on the database level.
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.
Yes it shouldn't. Honestly, I don't remember exactly why I added that. However, I do know for a fact that if you fill out the event add form and set either one of the dates to be an invalid one, when you submit it would give you a TypeError due to comparing NoneType and a datetime.datetime. That's probably why I added that when I was testing some things, but I should probably just remove this change.
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's up for handling in the form's logic though, not model's
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.
Yea but I was just looking where the error happened and changed that. I'll just remove this change then.
core/forms.py
Outdated
super(LateStartEventForm, self).__init__(*args, **kwargs) | ||
|
||
try: | ||
self.fields["organization"].initial = models.Organization.objects.get(name='SAC') |
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 should be querying organizations by pk instead of name
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.
eh, this way is honestly more adaptable as not all db instance will have the same SAC PK... but on this it should be the "School" org
see #285 (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.
What do you mean the "school" organization? Is that not just SAC? Also, for creating a school if it doesn't exist, would you just make the owner and execs just the admin currently using the form?
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.
No, there is a school org that is behind something like a late start or an admin related presentation.
As for the user, just pick the first created superuser (filter by date created and is_superuser).first()
Looks good and works fine 👍 |
LGTM! |
Faster way to create late starts through a form under events at /admin/core/event/createLateStart/. Currently the only way to access the form is by typing out the url, which needs to be changed but I am not sure where to make the form accessible from. The form does redirect the user to the events page after a successful creation of a late start event.
Screenshot of the form: