Skip to content

Commit

Permalink
Don't send emails for flagging
Browse files Browse the repository at this point in the history
  • Loading branch information
knrafto committed Feb 12, 2016
1 parent 1aedbba commit 80fca8d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 31 deletions.
3 changes: 0 additions & 3 deletions server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import json
from datetime import datetime as dt

from server.utils import send_email, group_action_email, flag_change_email
from server.constants import VALID_ROLES, STUDENT_ROLE, STAFF_ROLES

convention = {
Expand Down Expand Up @@ -226,7 +225,6 @@ def unflag(self, backup_id, member_ids):
if not backup:
raise BadRequest('Could not find backup')
backup.flagged = False
flag_change_email(member_ids, self)

def _unflag_all(self, member_ids):
"""Unflag all submissions by members of MEMBER_IDS."""
Expand All @@ -237,7 +235,6 @@ def _unflag_all(self, member_ids):
).one_or_none()
if backup:
backup.flagged = False
flag_change_email(member_ids, self)

def offering_name(self):
""" Returns the assignment name without the course offering.
Expand Down
32 changes: 4 additions & 28 deletions server/utils.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
import os
import logging
from urllib.parse import urlparse, urljoin

from flask import render_template, url_for
from hashids import Hashids
from premailer import transform
import sendgrid
from werkzeug.routing import BaseConverter, ValidationError
from urllib.parse import urlparse, urljoin

from server.extensions import cache
from flask import render_template, url_for

import sendgrid
from premailer import transform

sg = sendgrid.SendGridClient(os.getenv('SENDGRID_API_KEY'), None, raise_errors=True)

# To deal with circular imports
class ModelProxy(object):
def __getattribute__(self, key):
import server.models as models
return models.__getattribute__(key)

ModelProxy = ModelProxy()


# ID hashing configuration.
# DO NOT CHANGE ONCE THE APP IS PUBLICLY AVAILABLE. You will break every
# link with an ID in it.
Expand Down Expand Up @@ -56,9 +46,6 @@ def to_python(self, value):
def to_url(self, value):
return encode_id(value)




def is_safe_redirect_url(request, target):
host_url = urlparse(request.host_url)
redirect_url = urlparse(urljoin(request.host_url, target))
Expand All @@ -69,17 +56,6 @@ def group_action_email(members, subject, text):
emails = [m.user.email for m in members]
return send_email(emails, subject, text)

def flag_change_email(member_ids, assign):
emails = [ModelProxy.User.query.get(m).email for m in member_ids]
subject = "{} submission has changed".format(assign.display_name)
text = "The {} submission that is flagged for grading has been updated".format(assign.display_name)

link_text = "View Flagged Submission"
link = "http://okpy.org/" + url_for('student.assignment',
course=assign.course.offering, assign=assign.offering_name())

return send_email(emails, subject, text, link_text=link_text, link=link)

def invite_email(member, recipient, assignment):
subject = "{} group invitation".format(assignment.display_name)
text = "{} has invited you to join their group".format(member.email)
Expand Down

0 comments on commit 80fca8d

Please sign in to comment.