codebar / planner

🗓 the main codebar site
https://codebar.io
MIT License
92 stars 193 forks source link

Any event invitations should not be emailed to banned members #1259

Closed despo closed 4 years ago

despo commented 4 years ago

Description of the issue 📄

Even though banned members are unable to RSVP to the monthlies, they still receive invitations.

The process sending out monthlies invitations should be updated to not include banned members.

Screenshots 📷

Steps to fix 🛠

Have a look at InvitationManager as thsi is where all event invitations are trigerred from app/models/invitation_manager.rb

To do 📋

notapatch commented 4 years ago

Quick clarification @despo: so emails generated by all of these methods?

  # app/models/invitation_manager.rb
  def send_event_emails(event, chapter)
  def send_monthly_attendance_reminder_emails(monthly)
  def send_course_emails(course)

Or just send_monthly_attendance_reminder_emails ?


If anyone reading this wants to have a go, please do...

There seems to be a scope in member called not_banned that might be useful.

Class Member
  ...
  scope :not_banned, lambda {
                       joins('LEFT OUTER JOIN bans ON members.id = bans.member_id')
                         .where('bans.id is NULL or bans.expires_at < CURRENT_DATE')
                     }
 ...
despo commented 4 years ago

@notapatch yes the intention for this issue is to verify all type of event email invitations.

But, by having a brief look I think only the monthlies reminder emails (send_monthly_attendance_reminder_emails) would have to be updated as it seems like the Member in_group scope already takes not_banned into account so most methods don't require any updates.

  def chapter_students(chapter)
    Member.in_group(chapter.groups.students)
  end

  def chapter_coaches(chapter)
    Member.in_group(chapter.groups.coaches)
  end
end

https://github.com/codebar/planner/blob/master/app/models/invitation_manager.rb#L45

However, I am mostly interested in the tests being expanded to cover the non banned member scenario even for the methods that don't require any change, and this would include tests for methods included in https://github.com/codebar/planner/blob/master/app/models/concerns/workshop_invitation_manager_concerns.rb as well.

And it would be an added bonus to also move this in the InvitationManager https://github.com/codebar/planner/blob/master/app/controllers/admin/meetings_controller.rb#L54 and to handle emails being sent out asynchronously