示例#1
0
 def send_notification(self):
     subject = _('You have been added to a proposal at LCO.global')
     message = render_to_string('proposals/added.txt', {
         'proposal': self.proposal,
         'user': self.user,
     })
     send_mail.send(subject, message, '*****@*****.**',
                    [self.user.email])
示例#2
0
    def send_invitation(self):
        subject = _('You have been added to a proposal at LCO.global')
        message = render_to_string('proposals/invitation.txt', {
            'proposal': self.proposal,
            'url': reverse('registration_register')
        })

        send_mail.send(subject, message, '*****@*****.**', [self.email])
        self.sent = timezone.now()
        self.save()
示例#3
0
 def send_notification(self):
     subject = _(f'You have been added to a proposal at {settings.ORGANIZATION_NAME}')
     message = render_to_string(
         'proposals/added.txt',
         {
             'proposal': self.proposal,
             'user': self.user,
             'organization_name': settings.ORGANIZATION_NAME,
             'observation_portal_base_url': settings.OBSERVATION_PORTAL_BASE_URL
         }
     )
     send_mail.send(subject, message, settings.ORGANIZATION_EMAIL, [self.user.email])
示例#4
0
 def post(self, request):
     request_serializer = self.get_request_serializer(data=request.data)
     if request_serializer.is_valid():
         message = 'User {0} would like their account removed.\nReason:\n {1}'.format(
             request.user.email, request_serializer.validated_data['reason']
         )
         send_mail.send(
             'Account removal request submitted', message, settings.ORGANIZATION_EMAIL, [settings.ORGANIZATION_SUPPORT_EMAIL]
         )
         response_serializer = self.get_response_serializer({'message': 'Account removal request successfully submitted.'})
         return Response(response_serializer.data, status=status.HTTP_200_OK)
     else:
         return Response(request_serializer.errors, status=status.HTTP_400_BAD_REQUEST)
示例#5
0
def send_email_if_ddt_submission(science_application):
    is_submitted = science_application.status == ScienceApplication.SUBMITTED
    is_ddt = science_application.call.proposal_type == Call.DDT_PROPOSAL
    if is_submitted and is_ddt:
        message = render_to_string('sciapplications/ddt_submitted.txt', {
            'ddt': science_application,
            'detail_url': settings.SCIENCE_APPLICATION_DETAIL_URL.format(sciapp_id=science_application.id),
            'organization_name': settings.ORGANIZATION_NAME
        })
        send_mail.send(
            f'{settings.ORGANIZATION_NAME} Director\'s Discretionary Time Submission',
            message,
            settings.ORGANIZATION_EMAIL,
            [science_application.submitter.email, settings.ORGANIZATION_DDT_EMAIL]
        )
示例#6
0
    def send_invitation(self):
        subject = _(f'You have been added to a proposal at {settings.ORGANIZATION_NAME}')
        message = render_to_string(
            'proposals/invitation.txt',
            {
                'proposal': self.proposal,
                'url': reverse('registration_register'),
                'organization_name': settings.ORGANIZATION_NAME,
                'observation_portal_base_url': settings.OBSERVATION_PORTAL_BASE_URL
            }
        )

        send_mail.send(subject, message, settings.ORGANIZATION_EMAIL, [self.email])
        self.sent = timezone.now()
        self.save()
示例#7
0
    def send_time_allocation_reminder(self):
        if self.pi:
            subject = _(f'Your {settings.ORGANIZATION_NAME} Time Allocation Summary')
            message = render_to_string(
                'proposals/timeallocationreminder.html',
                {
                    'proposal': self,
                    'allocations': self.timeallocation_set.filter(semester=self.current_semester),
                    'organization_name': settings.ORGANIZATION_NAME
                }
            )
            plain_message = strip_tags(message)

            send_mail.send(subject, plain_message, settings.ORGANIZATION_EMAIL, [self.pi.email], html_message=message)
        else:
            logger.warn('Proposal {} does not have a PI!'.format(self))
示例#8
0
    def send_time_allocation_reminder(self):
        if self.pi:
            subject = _('Your LCO Time Allocation Summary')
            message = render_to_string(
                'proposals/timeallocationreminder.html', {
                    'proposal':
                    self,
                    'allocations':
                    self.timeallocation_set.filter(
                        semester=self.current_semester)
                })
            plain_message = strip_tags(message)

            send_mail.send(subject,
                           plain_message,
                           '*****@*****.**', [self.pi.email],
                           html_message=message)
        else:
            logger.warn('Proposal {} does not have a PI!'.format(self))
示例#9
0
 def send_approved_notification(self):
     subject = _('Your proposal at LCO.global has been approved')
     message = render_to_string(
         'sciapplications/approved.txt', {
             'proposal':
             self.proposal,
             'semester':
             self.call.semester,
             'semester_already_started':
             self.call.semester.start < timezone.now(),
         })
     # Find the email to send the notification to. The proposal will have been created at this point, but the pi on
     # the proposal might not be set yet if the pi has not a registered an account. In that case, use the email
     # as set on the science application.
     pi_email = self.proposal.pi.email if self.proposal.pi else self.pi
     email_sent = True
     try:
         send_mail.send(subject, message, '*****@*****.**', [pi_email])
     except smtplib.SMTPException:
         email_sent = False
     return email_sent
 def send_approved_notification(self):
     subject = _(f'Your proposal at {settings.ORGANIZATION_NAME} has been approved')
     message = render_to_string(
         'sciapplications/approved.txt',
         {
             'proposal': self.proposal,
             'semester': self.call.semester,
             'semester_already_started': self.call.semester.start < timezone.now(),
             'organization_name': settings.ORGANIZATION_NAME,
             'observation_portal_base_url': settings.OBSERVATION_PORTAL_BASE_URL
         }
     )
     # Find the email to send the notification to. The proposal will have been created at this point, but the pi on
     # the proposal might not be set yet if the pi has not a registered an account. In that case, use the email
     # as set on the science application.
     pi_email = self.proposal.pi.email if self.proposal.pi else self.pi
     email_sent = True
     try:
         send_mail.send(subject, message, settings.ORGANIZATION_EMAIL, [pi_email])
     except smtplib.SMTPException:
         email_sent = False
     return email_sent
示例#11
0
 def send_email(self, user):
     message = 'User {0} would like their account removed.\nReason:\n {1}'.format(
         user.email, self.cleaned_data['reason'])
     send_mail.send('Account removal request submitted', message,
                    '*****@*****.**', ['*****@*****.**'])
示例#12
0
def ddt_submitted_email(sciproposal):
    message = render_to_string('sciapplications/ddt_submitted.txt',
                               {'ddt': sciproposal})
    send_mail.send('LCO Director\'s Discretionary Time Submission', message,
                   '*****@*****.**',
                   [sciproposal.submitter.email, '*****@*****.**'])