コード例 #1
0
def on_new_successful_delivery(sender, delivery, **kwargs):
    deadline = delivery.deadline
    assignment_group = deadline.assignment_group
    assignment = assignment_group.parentnode
    period = assignment.parentnode
    subject = period.parentnode
    user_list = [candidate.student
                 for candidate in assignment_group.candidates.all()]
    url = create_absolute_show_delivery_url(delivery)

    files = ''
    for fm in delivery.filemetas.all():
        files += u' - {0} ({1})\n'.format(fm.filename, filesizeformat(fm.size))

    email_subject = u'Receipt for delivery on {0}'.format(assignment.get_path())
    email_message = (u'This is a receipt for your delivery.\n\n'
                     u'Subject: {subject}\n'
                     u'Period: {period}\n'
                     u'Assignment: {assignment}\n'
                     u'Deadline: {deadline}\n'
                     u'Delivery number: {deliverynumer}\n'
                     u'Time of delivery: {time_of_delivery}\n'
                     u'Files:\n{files}\n\n'
                     u'The delivery can be viewed at:\n'
                     u'{url}'.format(subject = subject.long_name,
                                     period = period.long_name,
                                     assignment = assignment.long_name,
                                     deadline = deadline.deadline.isoformat(),
                                     deliverynumer = delivery.number,
                                     time_of_delivery = delivery.time_of_delivery.isoformat(),
                                     files = files,
                                     url = url))
    send_message(email_subject, email_message, *user_list)
コード例 #2
0
ファイル: views.py プロジェクト: Nasmi1/devilry-django
    def get(self, request, pk):
        if not request.user.is_superuser:
            return HttpResponseForbidden('Requires superuser')
        try:
            user = get_user_model().objects.get(pk=pk)
        except get_user_model().DoesNotExist:
            return HttpResponseNotFound('ERROR: User "#{}" does not exist'.format(pk))

        if not request.user.useremail_set.exists():
            return HttpResponseBadRequest('ERROR: YOU ({user}) have no email address'.format(
                user=request.user))
        if not user.useremail_set.exists():
            return HttpResponseBadRequest('ERROR: User "{user}" has no email address'.format(
                user=user))

        subject = 'Test email from Devilry.'
        body = emailbodytpl.format(username=request.user.shortname,
                                   frontpageurl=create_absolute_url('/'),
                                   superuseremail=request.user.useremail_set.first().email)

        send_message(subject, body, user)
        return render(request, 'send_email_to_users/email_sending_debug.django.html',
                      {'email': user.useremail_set.first().email,
                       'subject': subject,
                       'body': body},
                      content_type="text/html")
コード例 #3
0
def on_new_staticfeedback(sender, **kwargs):
    staticfeedback = kwargs['instance']
    delivery = staticfeedback.delivery
    deadline = delivery.deadline
    assignment_group = deadline.assignment_group
    assignment = assignment_group.parentnode
    period = assignment.parentnode
    subject = period.parentnode

    user_list = [candidate.student \
            for candidate in assignment_group.candidates.all()]

    url = create_absolute_show_delivery_url(delivery)
    email_subject = 'New feedback - {0}'.format(assignment.get_path())

    # Make sure the values that may contain non-ascii characters are utf-8
    unicode_kw = dict(subject = subject.long_name,
                      period = period.long_name,
                      assignment = assignment.long_name)
    for key, value in unicode_kw.iteritems():
        unicode_kw[key] = value.encode(CHARSET)

    email_message = ('One of your deliveries has new feedback.\n\n'
                     'Subject: {subject}\n'
                     'Period: {period}\n'
                     'Assignment: {assignment}\n'
                     'Deadline: {deadline}\n'
                     'Delivery number: {delivery}\n\n'
                     'The feedback can be viewed at:\n'
                     '{url}'.format(deadline = deadline.deadline.isoformat(),
                                    delivery = delivery.number,
                                    url = url,
                                    **unicode_kw))
    send_message(email_subject, email_message, *user_list)
コード例 #4
0
ファイル: base.py プロジェクト: devilry/devilry-django
    def _send_email(self):
        """
        Sends the email via `devilry.utils.devilry_email.send_message`.

        DO NOT call this method directly.
        """
        send_message(self.subject, self.message_content_html, *[self.user], is_html=True)
コード例 #5
0
    def _send_email(self):
        """
        Sends the email via `devilry.utils.devilry_email.send_message`.

        DO NOT call this method directly.
        """
        send_message(self.subject,
                     self.message_content_html,
                     *[self.user],
                     is_html=True)
コード例 #6
0
def _send_success_email(detektorassignment):
    assignmentpath = detektorassignment.assignment.get_path()
    message = render_to_string('devilry_detektor/admin/run_detektor_on_assignment_finished_email.django.txt', {
        'assignment': assignmentpath,
        'resulturl': u'{}{}'.format(
            settings.DEVILRY_SCHEME_AND_DOMAIN,
            reverse('devilry_detektor_admin_assignmentassembly',
                    kwargs={'assignmentid': detektorassignment.assignment.id}))
    })
    subject = _(u'Programming code similarity check processing for %(assignment)s is finished') % {
        'assignment': assignmentpath}
    send_message(
        subject, message, detektorassignment.processing_started_by)
コード例 #7
0
def _send_success_email(detektorassignment):
    assignmentpath = detektorassignment.assignment.get_path()
    message = render_to_string(
        'devilry_detektor/admin/run_detektor_on_assignment_finished_email.django.txt',
        {
            'assignment':
            assignmentpath,
            'resulturl':
            u'{}{}'.format(
                settings.DEVILRY_SCHEME_AND_DOMAIN,
                reverse(
                    'devilry_detektor_admin_assignmentassembly',
                    kwargs={'assignmentid': detektorassignment.assignment.id}))
        })
    subject = _(
        u'Programming code similarity check processing for %(assignment)s is finished'
    ) % {
        'assignment': assignmentpath
    }
    send_message(subject, message, detektorassignment.processing_started_by)
コード例 #8
0
    def get(self, request, username):
        if not request.user.is_superuser:
            return HttpResponseForbidden('Requires superuser')
        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            return HttpResponseNotFound('ERROR: User "{username}" does not exist'.format(**vars()))

        if not request.user.email:
            return HttpResponseBadRequest('ERROR: YOU ({username}) have no email address'.format(username=request.user.username))
        if not user.email:
            return HttpResponseBadRequest('ERROR: User "{username}" has no email address'.format(**vars()))

        subject = 'Test email from Devilry.'
        body = emailbodytpl.format(username=request.user.username,
                                   frontpageurl=create_absolute_url(reverse('devilry_frontpage')),
                                   superuseremail=request.user.email)

        send_message(subject, body, user)
        return render(request, 'send_email_to_users/email_sending_debug.django.html',
                      {'email': user.email,
                       'subject': subject,
                       'body': body},
                      content_type="text/html")