Skip to content
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

Merged
merged 5 commits into from
Nov 11, 2024

Conversation

imaegg11
Copy link
Contributor

@imaegg11 imaegg11 commented Nov 2, 2024

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

@JasonLovesDoggo
Copy link
Member

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

Copy link
Member

@JasonLovesDoggo JasonLovesDoggo left a 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

@@ -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:
Copy link
Member

Choose a reason for hiding this comment

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

Reason for changing this?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor Author

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')
Copy link
Contributor

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

Copy link
Member

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)

Copy link
Contributor Author

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?

Copy link
Member

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

@imaegg11
Copy link
Contributor Author

imaegg11 commented Nov 6, 2024

Alright, new commits should have fixed everything. Form is now accessible from the events admin page through a button next to add event.

Screenshot:
image

@pinwheeeel
Copy link
Contributor

Looks good and works fine 👍

@JasonLovesDoggo
Copy link
Member

LGTM!

@JasonLovesDoggo JasonLovesDoggo merged commit 87628d5 into wlmac:develop Nov 11, 2024
3 checks passed
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.

3 participants