From 9f2eeefb7f089eca8099e1f8e7531ace2054266d Mon Sep 17 00:00:00 2001 From: Michael Graff Date: Sat, 16 Jul 2016 17:19:19 -0700 Subject: [PATCH] update mailer --- app/mailers/instructor_mailer.rb | 2 +- .../instructor_mailer/_instances.html.haml | 5 +- .../instructor_mailer/send_message.html.haml | 140 ++++-------------- bin/instructor-schedule-mailer.rb | 15 ++ 4 files changed, 44 insertions(+), 118 deletions(-) create mode 100644 bin/instructor-schedule-mailer.rb diff --git a/app/mailers/instructor_mailer.rb b/app/mailers/instructor_mailer.rb index 2a13c84..b3d2967 100644 --- a/app/mailers/instructor_mailer.rb +++ b/app/mailers/instructor_mailer.rb @@ -12,7 +12,7 @@ class InstructorMailer < ActionMailer::Base def send_message(user, subject) @user = user ids = Instructable.where(user_id: @user.id).pluck(:id) - @instances = Instance.where(instructable_id: ids).includes(:instructable) + @instances = Instance.where(instructable_id: ids).includes(:instructable).order(:start_time) @name = @user.titled_sca_name mail(to: user.email, subject: "Pennsic University: #{subject}") diff --git a/app/views/instructor_mailer/_instances.html.haml b/app/views/instructor_mailer/_instances.html.haml index 12d52a4..937c5f1 100644 --- a/app/views/instructor_mailer/_instances.html.haml +++ b/app/views/instructor_mailer/_instances.html.haml @@ -7,11 +7,12 @@ %th Name %tbody - @instances.each do |instance| + - next unless instance.start_time %tr %td - = instance.start_time.strftime('%m-%d') + = instance.start_time.strftime('%a, %b %d') %br - = instance.start_time.strftime('%H:%M') + = instance.start_time.strftime('%I:%M %p') %td= pluralize(instance.instructable.duration, 'hour') %td= instance.formatted_location %td= instance.instructable.name diff --git a/app/views/instructor_mailer/send_message.html.haml b/app/views/instructor_mailer/send_message.html.haml index 0e10dcf..aa45ff9 100644 --- a/app/views/instructor_mailer/send_message.html.haml +++ b/app/views/instructor_mailer/send_message.html.haml @@ -1,8 +1,9 @@ -%p Greetings #{@name}: +%p Dear #{@name.strip}: %p - Thank you for volunteering to teach at the Pennsic University. - Your classes are: + Thank you very much for choosing to teach at Pennsic University! + We are very happy that you have done so! In fact, we couldn't do it with out you! + According to our records we see that you have the following dates and locations for your upcoming classes = render 'instances' @@ -14,124 +15,33 @@ and location for your class. %p - I know this looks like a tl;dnr block of text but please read the - following important points for all instructors: + Please keep the following instructions in mind for your classes: %ul - %li - Let the University know, as soon as possible, if you must cancel - or change the time or day of your class. E-mail the registrar at - Pennsic Registrar - #{link_to 'pennsicuregistrar@gmail.com', 'mailto:pennsicuregistrar@gmail.com'}. - Changes will be made - in advance if they are received before 6 pm EDT on Friday, July 19th. - After that, you may email and it will be handled on-site, or you may - come to University Point and talk to any shift supervisor. - - %li - Sign in at University Point after you get to Pennsic. University Point - will be open from 1 pm - 4 pm on Monday, July 22; from 8:30 am to - 5 pm July 23 through August 1. Please sign in as early as possible - so we know that you are on site in case of questions or problems - relative to your class. You will also be able to pick up your - teacher token at that time. - - %li - Start and end classes on time. Remember you need to be out of the - tent a few minutes before the scheduled end of your class to allow - the next class to begin on time. For an hour long class, expect to - use 50 to 55 minutes of class time. - - %li - If you have requested a “messy” class tent, please be aware that while - the tent has a sink with running water, there is no drain. - Water simply spills out onto the grass. - If you will be cleaning up something that will leave a residue - you must bring your own bucket or pan to drain into and dispose - of your waste water properly. - - %li - If you will be using a heat source, you must adhere to the - following rules: - - %ul - %li - Classes using heat sources must move tables as far away from - tent walls as possible to minimize the chance of damage to - the canvas. - %li - Small open flame sources such as candles or Sterno cans must - be placed on a fireproof surface to prevent damage to tabletops. - %li - Larger flame sources such as camp stoves or charcoal burners - must be securely set on a level tabletop and make use of a - flame shield/windbreak if available. - %li - Propane torches, such as those used for glass bead making, - must be securely affixed to the edge of the table (not hand-held - or standing on the tabletop) at all times and pointed away - from tent walls. - %li - All active heat sources must be supervised at all times. - - %li - Clean up the tent when you are done with your class. - - %ul - %li - When working with hot glass, a heatproof surface must cover - all tabletops to reduce the possibility of damage or fire. - %li - You must devise a way of collecting any fragments of - broken glass from the tent interior to avoid the - possibility of injury to others. - %li - If your class includes a process that may produce sharp - fragments or shards (including but not limited to wood or - metalworking), you must devise a way to collect any sharp - fragments from the tent at the end of your class to avoid the - possibility of injury to others. - - %li - White Boards are available just prior to your class at University Point. - It is your responsibility to both pick-up and return the White Boards - and markers. If the Point is closed for the night, put the White - Board and markers inside on a table. - - %li - If you wish to open the tent, see posted directions for raising - the walls. Please, DO NOT EVER disconnect the sides. This makes - closing them difficult and also makes the canvas more likely to - be damaged. - - %li - If you are the last class in a tent, on any day, please lower the - tent sides if they are raised (directions will be posted) and close - the front. If it is impossible for you to do this, please stop by - the Point and let us know so we can close them. - - %li - There is still space for more classes. If you, or anyone you know, - wishes to add a class, please come to University Point to schedule it. - - %li - Changes/Adds/Deletes will be updated on the Pennsic War web site, - posted on Pennsic University's Facebook page, posted on the boards - at the Point, and published in the Pennsic Independent. - - %li - Volunteers are still needed for staffing University Point. - Encourage your friends to volunteer. + %li University Point opens officially Tuesday Morning August 2 at 9:00 am and will be open each day until 4:30 thearafter Thursday August 11 + %li Please remember to sign in and register as early as possible at University Point after you get on site. + %li We will start registering teachers Tuesday August 2 at 9:00 am and will continue for the duration of the war + %li If you need class aids, such as dry erase boards and pens, they are available on a first come first serve basis at University Point. + %li Please remind all students to return any chairs borrowed for your class after every class. + %li Tents will be provided with special ropes to raise and quickly lower the sides. PLEASE USE THEM. DO NOT USE THE WALL CLIPS. + %li If your class is the last scheduled class for the day in the tent, please drop the tent walls. + %li If "that typical Pennsic storm" looms, please drop the tent walls, and raise them after the weather has cleared. + %li If you need help or instruction on raising or lowering the tent walls, please advise University Point of your difficulty. + %li Electricity in any tents is not provided as a public resource. Please do not abuse this resource. + %li Heat sources of any kind are only allowed in designated tents. If you are unsure, ask at University Point before your class. + %li Please be patient with us, we are also hot and tired and it is also our vacation! We promise that we will try to do the same for the same reasons. + %li If you have any questions at all, ask us, do not assume. %p - Thank you for teaching and helping make the University at Pennsic - the outstanding learning venue that it has become. + Thank you very much for teaching at Pennsic 45. + The University and the Cultural Affairs staff are very grateful to you for volunteering! + Teaching prospers the SCA in ways that not other activity can. %p - In Service, + Thank you %br - Baroness Gwynnyd of York, Chancellor + Capt Elias Gedney %br - Capt. Elias Gedney, University Point Coordinator + Pennsic University Chancellor %br - TH Lady Artimisia Lacebrayder, Registrar + Pennsic 45 diff --git a/bin/instructor-schedule-mailer.rb b/bin/instructor-schedule-mailer.rb new file mode 100644 index 0000000..d278741 --- /dev/null +++ b/bin/instructor-schedule-mailer.rb @@ -0,0 +1,15 @@ +instructor_ids = Instructable.pluck(:user_id).uniq.compact + +instructors = User.where(id: instructor_ids) + +instructors.each do |instructor| + if instructor.instructables.count == 0 + puts "Skipping instructor #{instructor.name} (#{instructor.email}): no instructables" + next + end + + mailer = InstructorMailer.send_message(instructor, 'Class List') + if instructor.email == 'explorer@flame.org' + mailer.deliver + end +end