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

Implement individual students stickying #1723

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

JasonGrace2282
Copy link
Member

@JasonGrace2282 JasonGrace2282 commented Sep 25, 2024

Proposed changes

Allow stickying individual students to a scheduled 8th period.

Brief description of change

Closes #1719

  • Add a ManyToManyField to User called sticky_students.
  • There is also a new method called EighthScheduledActivity.is_user_stickied(user) which checks if an individual user is stickied, replacing the old get_sticky method.

You can edit the stickied students at /eighth/admin/scheduling/schedule?activity=<some_activity_pk>

@JasonGrace2282 JasonGrace2282 force-pushed the individual-sticky branch 4 times, most recently from 8c235c7 to df67d6c Compare September 25, 2024 20:42
@JasonGrace2282 JasonGrace2282 marked this pull request as ready for review September 25, 2024 20:43
@JasonGrace2282 JasonGrace2282 requested a review from a team as a code owner September 25, 2024 20:43
@JasonGrace2282 JasonGrace2282 force-pushed the individual-sticky branch 5 times, most recently from 55b02c9 to 9bad520 Compare September 26, 2024 03:03
Copy link
Member

@alanzhu0 alanzhu0 left a comment

Choose a reason for hiding this comment

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

Great work - it looks like the core feature is working.

I don't know if you've noticed this, maybe it only occurs when you have a fairly large scheduling page (lots of instances), but the page load time is very slow. Run the dev autogenerate data scripts if you haven't. I'm getting 15s page load vs. 2s on production, and my dev is usually faster than prod. I assume it's due to populating all the fields with all those users. So we have to optimize this somehow. Maybe use JS and only populate the field when the user clicks on it?

And a few feature suggestions:

  • Can you distinguish between activity-sticky activities and user-sticky activities to the student? Right now they look the same to the student. Probably make the badge say "User Sticky" with an explanation tooltip instead of just "Sticky."
  • What do you think about sending an email to the user when they get user-sticked into an activity?

@JasonGrace2282
Copy link
Member Author

Maybe use JS and only populate the field when the user clicks on it?

I just pushed a commit that populates it as soon as the page has loaded. Could you check if that's fast enough for you?

As for sending an email, I'm not sure how much I would like that as a user - but I could also see it being really helpful for some people. As such, I'm -0 on the idea: if you really think it's useful/important, I can implement it.

@JasonGrace2282 JasonGrace2282 force-pushed the individual-sticky branch 2 times, most recently from 4ca8bd3 to 67d71e7 Compare October 13, 2024 13:37
Copy link
Member

@alanzhu0 alanzhu0 left a comment

Choose a reason for hiding this comment

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

Ok, this is great, it loads very quickly now. But it doesn't seem to work anymore? When I put a user in and save it doesn't actually do anything, and the field gets wiped? Is it on my end?

@alanzhu0
Copy link
Member

Did you change the name to 'user sticky'? Also yes - email would be helpful if you can add that.

@JasonGrace2282 JasonGrace2282 force-pushed the individual-sticky branch 3 times, most recently from 30fe65a to 781dc23 Compare October 19, 2024 19:28
@JasonGrace2282
Copy link
Member Author

I haven't implemented email yet (if I get a chance later, I can do that), but everything else should be done, namely:

  • Fixing the bug with ajax
  • Changing the label to individual sticky

Copy link
Member

@alanzhu0 alanzhu0 left a comment

Choose a reason for hiding this comment

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

Looking good and almost there

intranet/apps/eighth/views/admin/scheduling.py Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Oct 20, 2024

Coverage Status

coverage: 79.118% (+0.02%) from 79.094%
when pulling 19ffbfd on JasonGrace2282:individual-sticky
into 129cfbc on tjcsl:dev.

signup = EighthSignup.objects.filter(user=user, scheduled_activity__block=self.block).first()
if signup is not None:
signup.remove_signup(user, force=True)
EighthSignup.objects.create_signup(user, scheduled_activity=self)
Copy link
Member

Choose a reason for hiding this comment

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

Still not the right way to do it, I think...again look at the signup view. I took a look myself and I believe you need to use EighthScheduledActivity.add_user

intranet/apps/eighth/models.py Outdated Show resolved Hide resolved
You have been stickied into {{ activity.activity.name }} on {{ activity.date }} ({{ activity.block_letter }}).

If there has been a mistake with this change, please contact the 8th period office.
Have a nice day!
Copy link
Member

Choose a reason for hiding this comment

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

I dont think you need this lol

Copy link
Member Author

Choose a reason for hiding this comment

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

It never hurts to tell people to have a nice day :)

@@ -1097,10 +1115,50 @@ def notify_waitlist(self, waitlists: Iterable["EighthWaitlist"]):
[waitlist.user.primary_email_address],
)

def set_sticky_students(self, users: "Sequence[AbstractBaseUser]") -> None:
Copy link
Member

Choose a reason for hiding this comment

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

yes good

# note: this will send separate emails to each student for each activity they are stickied in
new_stickied_students = (user for user in users if user not in old_sticky_students)
unstickied_students = (user for user in old_sticky_students if user not in users)
email_send_task.delay(
Copy link
Member

Choose a reason for hiding this comment

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

i think this works

@alanzhu0 alanzhu0 merged commit 49de27c into tjcsl:dev Oct 23, 2024
5 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.

Individual User Sticky to Activity
3 participants