示例#1
0
    def send_request(self, request=None):
        domain = get_domain(request)

        context = {
            "club_name":
            self.club.name,
            "edit_url":
            "{}#member".format(
                settings.EDIT_URL.format(domain=domain, club=self.club.code)),
            "full_name":
            self.person.get_full_name(),
        }

        owner_emails = list(
            self.club.membership_set.filter(
                role__lte=Membership.ROLE_OFFICER).values_list("person__email",
                                                               flat=True))

        send_mail_helper(
            name="request",
            subject="Membership Request from {} for {}".format(
                self.person.get_full_name(), self.club.name),
            emails=owner_emails,
            context=context,
        )
示例#2
0
    def send_approval_email(self, request=None, change=False):
        """
        Send either an approval or rejection email to the club officers
        after their club has been reviewed.
        """
        domain = get_domain(request)

        context = {
            "name": self.name,
            "year": timezone.now().year,
            "approved": self.approved,
            "approved_comment": self.approved_comment,
            "view_url": settings.VIEW_URL.format(domain=domain,
                                                 club=self.code),
            "edit_url": settings.EDIT_URL.format(domain=domain,
                                                 club=self.code),
            "change": change,
        }

        emails = self.get_officer_emails()

        if emails:
            send_mail_helper(
                name="approval_status",
                subject="{}{} {} on {}".format(
                    "Changes to " if change else "",
                    self.name,
                    "accepted" if self.approved else "not approved",
                    settings.BRANDING_SITE_NAME,
                ),
                emails=emails,
                context=context,
            )
示例#3
0
    def send_owner_invite(self, request=None):
        """
        Send the initial email invitation to owner(s) of the club.
        """
        if self.role > Membership.ROLE_OWNER:
            raise ValueError(
                "This invite should grant owner permissions if sending out the owner email!"
            )

        domain = get_domain(request)

        context = {
            "name":
            self.club.name,
            "view_url":
            settings.VIEW_URL.format(domain=domain, club=self.club.code),
            "url":
            settings.INVITE_URL.format(domain=domain,
                                       id=self.id,
                                       token=self.token,
                                       club=self.club.code),
        }

        send_mail_helper(
            name="owner",
            subject=f"Welcome to {settings.BRANDING_SITE_NAME}!",
            emails=[self.email],
            context=context,
        )
示例#4
0
    def send_confirmation_email(self, request=None):
        """
        Send an email to the club officers confirming that their club has been queued for approval.
        """
        domain = get_domain(request)

        emails = self.get_officer_emails()

        context = {
            "name": self.name,
            "view_url": settings.VIEW_URL.format(domain=domain,
                                                 club=self.code),
        }

        if emails:
            send_mail_helper(
                name="confirmation",
                subject=f"{self.name} has been queued for approval",
                emails=emails,
                context=context,
            )
示例#5
0
    def send_renewal_email(self, request=None):
        """
        Send an email notifying all club officers about renewing their approval with the
        Office of Student Affairs and registering for the SAC fair.
        """
        domain = get_domain(request)

        context = {
            "name": self.name,
            "url": settings.RENEWAL_URL.format(domain=domain, club=self.code),
        }

        emails = self.get_officer_emails()

        if emails:
            send_mail_helper(
                name="renew",
                subject="[ACTION REQUIRED] Renew {} and SAC Fair Registration".
                format(self.name),
                emails=emails,
                context=context,
            )
示例#6
0
    def send_mail(self, request=None):
        """
        Send the email associated with this invitation to the user.
        """
        domain = get_domain(request)

        context = {
            "token":
            self.token,
            "name":
            self.club.name,
            "id":
            self.id,
            "club_id":
            self.club.code,
            "sender":
            request.user if request is not None else {
                "username": settings.BRANDING_SITE_NAME,
                "email": settings.BRANDING_SITE_EMAIL
            },
            "role":
            self.role,
            "title":
            self.title,
            "url":
            settings.INVITE_URL.format(domain=domain,
                                       id=self.id,
                                       token=self.token,
                                       club=self.club.code),
        }

        send_mail_helper(
            name="invite",
            subject="Invitation to {}".format(self.club.name),
            emails=[self.email],
            context=context,
        )
示例#7
0
    def send_question_mail(self, request=None):
        domain = get_domain(request)

        owner_emails = list(
            self.club.membership_set.filter(
                role__lte=Membership.ROLE_OFFICER).values_list("person__email",
                                                               flat=True))

        context = {
            "name":
            self.club.name,
            "question":
            self.question,
            "url":
            settings.QUESTION_URL.format(domain=domain, club=self.club.code),
        }

        if owner_emails:
            send_mail_helper(
                name="question",
                subject="Question for {}".format(self.club.name),
                emails=owner_emails,
                context=context,
            )
示例#8
0
    def send_virtual_fair_email(self,
                                request=None,
                                email="setup",
                                fair=None,
                                emails=None,
                                extra=False):
        """
        Send an email to all club officers about setting up their club for the virtual fair.

        If no list of emails is specified, the officer emails for this club will be used.
        If no fair is specified, the closest upcoming fair will be used.
        """
        domain = get_domain(request)

        now = timezone.now()

        if fair is None:
            fair = ClubFair.objects.filter(
                start_time__gte=now).order_by("start_time").first()

        eastern = pytz.timezone("America/New_York")

        events = self.events.filter(start_time__gte=fair.start_time,
                                    end_time__lte=fair.end_time,
                                    type=Event.FAIR).order_by("start_time")
        event = events.first()
        events = [{
            "time":
            f"{timezone.localtime(start, eastern).strftime('%B %d, %Y %I:%M %p')} - "
            f"{timezone.localtime(end, eastern).strftime('%B %d, %Y %I:%M %p')} ET"
        } for start, end in events.values_list("start_time", "end_time")]

        prefix = ("ACTION REQUIRED" if event is None or not event.url
                  or "zoom.us" not in event.url else "REMINDER")

        # if one day before fair, change prefix to urgent
        if fair.start_time - datetime.timedelta(days=1) < now:
            prefix = "URGENT"

        # if no emails specified, send to officers
        if emails is None:
            emails = self.get_officer_emails()

        context = {
            "name": self.name,
            "prefix": prefix,
            "guide_url": f"https://{domain}/guides/fair",
            "media_guide_url": f"https://{domain}/guides/media",
            "zoom_url": f"https://{domain}/zoom",
            "fair_url":
            f"https://{domain}/fair?fair={fair.id if fair is not None else ''}",
            "subscriptions_url":
            f"https://{domain}/club/{self.code}/edit#recruitment",
            "num_subscriptions": self.subscribe_set.count(),
            "fair": fair,
            "events": events,
            "extra": extra,
        }

        if emails:
            return send_mail_helper(
                name={
                    "setup": "fair_info",
                    "urgent": "fair_reminder",
                    "post": "fair_feedback_officers",
                }[email],
                subject=None,
                emails=emails,
                context=context,
            )
        return False