Beispiel #1
0
    def send_invite_notification(self, request):
        """
        Called to send the invite notification. Should be called
        right after creating the invite. Not called in save() to
        make message sending less coupled (to avoid any issues
        with testing and bulk creation of invites).

        :param request:
            A Django HttpRequest object. The only method used is
            the build_absolute_uri() method.

        :raise ValueError:
            If ``accepted==None``, or ``id==None``.
        """
        if self.accepted is not None:
            raise ValueError('Can not send notification for an accepted GroupInvite.')
        elif self.id is None:
            raise ValueError('Can not send notification for an unsaved GroupInvite.')
        sent_by_displayname = self.sent_by.get_full_name()
        assignment = self.group.assignment
        subject = _('Project group invite for {assignment}').format(assignment=assignment.get_path())
        template_name = 'devilry_core/groupinvite_invite.django.txt'
        url = request.build_absolute_uri(reverse('devilry_student_groupinvite_respond', kwargs={'invite_id': self.id}))
        send_templated_message(subject, template_name, {
            'sent_by_displayname': sent_by_displayname,
            'assignment': assignment.long_name,
            'subject': assignment.subject.long_name,
            'url': url
        }, self.sent_to)
Beispiel #2
0
    def send_invite_notification(self, request):
        """
        Called to send the invite notification. Should be called
        right after creating the invite. Not called in save() to
        make message sending less coupled (to avoid any issues
        with testing and bulk creation of invites).

        :param request:
            A Django HttpRequest object. The only method used is
            the build_absolute_uri() method.

        :raise ValueError:
            If ``accepted==None``, or ``id==None``.
        """
        if self.accepted is not None:
            raise ValueError(
                'Can not send notification for an accepted GroupInvite.')
        elif self.id is None:
            raise ValueError(
                'Can not send notification for an unsaved GroupInvite.')
        sent_by_displayname = self.sent_by.get_full_name()
        assignment = self.group.assignment
        subject = _('Project group invite for {assignment}').format(
            assignment=assignment.get_path())
        template_name = 'devilry_core/groupinvite_invite.django.txt'
        url = request.build_absolute_uri(
            reverse('devilry_student_groupinvite_respond',
                    kwargs={'invite_id': self.id}))
        send_templated_message(
            subject, template_name, {
                'sent_by_displayname': sent_by_displayname,
                'assignment': assignment.long_name,
                'subject': assignment.subject.long_name,
                'url': url
            }, self.sent_to)
Beispiel #3
0
 def _send_response_notification(self):
     sent_to_displayname = self.sent_to.get_full_name()
     if self.accepted:
         subject = _('{user} accepted your project group invite').format(user=sent_to_displayname)
         template_name = 'devilry_core/groupinvite_accepted.django.txt'
     else:
         subject = _('{user} rejected your project group invite').format(user=sent_to_displayname)
         template_name = 'devilry_core/groupinvite_rejected.django.txt'
     assignment = self.group.assignment
     send_templated_message(subject, template_name, {
         'sent_to_displayname': sent_to_displayname,
         'assignment': assignment.long_name,
         'subject': assignment.subject.long_name
     }, self.sent_by)
Beispiel #4
0
 def _send_response_notification(self):
     sent_to_displayname = self.sent_to.get_full_name()
     if self.accepted:
         subject = _('{user} accepted your project group invite').format(
             user=sent_to_displayname)
         template_name = 'devilry_core/groupinvite_accepted.django.txt'
     else:
         subject = _('{user} rejected your project group invite').format(
             user=sent_to_displayname)
         template_name = 'devilry_core/groupinvite_rejected.django.txt'
     assignment = self.group.assignment
     send_templated_message(
         subject, template_name, {
             'sent_to_displayname': sent_to_displayname,
             'assignment': assignment.long_name,
             'subject': assignment.subject.long_name
         }, self.sent_by)