Esempio n. 1
0
def send_registration_invitation(registration, inviter=None, message=None):
    text = render('/emails/registration_invitation.mako',
                  extra_vars={'registration': registration,
                              'inviter': inviter,
                              'message': message})
    msg = EmailMessage(_('Invitation to Ututi'), text)
    msg.send(registration.email)
Esempio n. 2
0
def teacher_confirmed_email(teacher, confirmed):
    """Send an email to a teacher once he has been confirmed."""
    if confirmed:
        text = render('/emails/teacher_confirmed.mako', extra_vars={'teacher': teacher, 'config':config})
    else:
        text = render('/emails/teacher_rejected.mako', extra_vars={'teacher': teacher, 'config':config})
    msg = EmailMessage(_('Your account has been confirmed!'), text, force=True)
    msg.send(teacher)
Esempio n. 3
0
def send_group_invitation_for_non_user(invitation, registration, message=None):
    """A method for handling user invitation to group emails for non users"""
    text = render('/emails/invitation_nonuser.mako',
                  extra_vars={'invitation': invitation,
                              'registration': registration,
                              'message': message})
    msg = EmailMessage(_('Ututi group invitation'), text)
    msg.send(registration.email)
Esempio n. 4
0
def teacher_request_email(user):
    """Notify team of a user requesting to become a teacher."""
    text = render('/emails/teacher_request.mako', extra_vars={'user': user})
    msg = EmailMessage(_('Request to be come a teacher!'), text, force=True)
    msg.send(config.get('ututi_email_from', '*****@*****.**'))

    for group in user.location.moderator_groups:
        msg.send(group.list_address)
Esempio n. 5
0
def teacher_registered_email(teacher):
    """Notify team of a new teacher."""
    text = render('/emails/teacher_registered.mako', extra_vars={'teacher': teacher})
    msg = EmailMessage(_('New teacher!'), text, force=True)
    msg.send(config.get('ututi_email_from', '*****@*****.**'))

    for group in teacher.location.moderator_groups:
        msg.send(group.list_address)
Esempio n. 6
0
 def send_email_message_js(self):
     if hasattr(self, 'form_result'):
         msg = EmailMessage(self.form_result['subject'],
                            self.form_result['message'],
                            sender=self.form_result['sender'],
                            force=True)
         for rcpt in self.form_result['recipients']:
             msg.send(rcpt)
         return {'success': True}
Esempio n. 7
0
def group_confirmation_email(group, user, status):
    """Send an email to the user when his request to join a group is confirmed."""
    if status:
        #the request has been confirmed
        text = render('/emails/group_confirmation.mako', extra_vars={'group': group, 'user': user})
    else:
        text = render('/emails/group_confirmation_deny.mako', extra_vars={'group': group, 'user': user})

    msg = EmailMessage(_('Ututi group membership confirmation'), text, force=True)
    msg.send(user)
Esempio n. 8
0
def send_group_invitation_for_user(invitation, email, message=None):
    """A method for handling user invitation to group emails."""
    from ututi.model import Email
    if invitation.user is not None:
        email_instance = Email.get(email)
        if email_instance.confirmed:
            #the user is already using ututi, send a message inviting him to join the group
            text = render('/emails/invitation_user.mako',
                          extra_vars={'invitation': invitation,
                                      'message': message})
            msg = EmailMessage(_('Ututi group invitation'), text)
            msg.send(email_instance.user)
Esempio n. 9
0
    def contacts(self):
        """Contact us form with send message functionality."""
        if hasattr(self, 'form_result'):
            name = self.form_result['name']
            email = self.form_result['email']
            message = self.form_result['message']
            text = render('/emails/contact_us.mako',
                          extra_vars={'name': name,
                                      'email': email,
                                      'message': message})
            msg = EmailMessage(_('Message to Ututi.com team'), text, force=True)
            msg.send('*****@*****.**')
            h.flash(_('Your message was succesfully sent.'))

        return self._contacts_form()
Esempio n. 10
0
def email_confirmation_request(user, email):
    for user_email in user.emails:
        if email.strip() == user_email.email.strip():
            hash = hashlib.md5(datetime.now().isoformat() + email).hexdigest()
            user_email.confirmation_key = hash
            meta.Session.commit()

            link = url_for(controller='profile', action='confirm_user_email', key=hash, qualified=True)
            text = render('/emails/confirm_email.mako',
                          extra_vars={'fullname': user.fullname,
                                      'link': link,
                                      'html': False})

            msg = EmailMessage(_('Confirm the email for Ututi'), text, force=True)
            msg.send(email)
Esempio n. 11
0
    def studentgroup_send_message(self, group):
        if hasattr(self, 'form_result'):
            subject = self.form_result['subject']
            message = self.form_result['message']

            #wrap the message with additional information
            msg_text = render('/emails/teacher_message.mako',
                              extra_vars={'teacher':c.user,
                                          'subject':subject,
                                          'message':message})
            if group.group is not None:
                recipient = group.group
                if recipient.mailinglist_enabled:
                    attachments = []
                    if self.form_result['file'] != '':
                        file = self.form_result['file']
                        f = File(file.filename, file.filename, mimetype=file.type)
                        f.store(file.file)
                        meta.Session.add(f)
                        meta.Session.commit()
                        attachments.append(f)

                    post_message(recipient,
                                 c.user,
                                 subject,
                                 msg_text,
                                 force=True,
                                 attachments=attachments)
                else:
                    attachments = []
                    if self.form_result['file'] != '':
                        attachments = [{'filename': self.form_result['file'].filename,
                                        'file': self.form_result['file'].file}]

                    msg = EmailMessage(_('Message from %(teacher_name)s: %(subject)s') % {
                                           'subject': subject,
                                           'teacher_name': c.user.fullname},
                                       msg_text,
                                       sender=recipient.list_address,
                                       attachments=attachments)

                    msg.send(group.group)

                    evt = TeacherMessageEvent()
                    evt.context = group.group
                    evt.data = '%s \n\n %s' % (subject, msg_text)
                    evt.user = c.user
                    meta.Session.add(evt)
                    meta.Session.commit()

            else:
                attachments = []
                if self.form_result['file'] != '':
                    attachments = [{'filename': self.form_result['file'].filename,
                                    'file': self.form_result['file'].file}]

                msg = EmailMessage(subject, msg_text, sender=c.user.email.email, force=True, attachments=attachments)
                msg.send(group.email)

            message = _(u'Message sent to %(group_title)s (%(group_email)s).') % {
                'group_title': group.title,
                'group_email': group.email}
            h.flash(message)

        redirect(url(controller='profile', action='dashboard'))
Esempio n. 12
0
def group_space_bought_email(group):
    """Send an email to all group users when private group space are bought."""
    text = render('/emails/group_space_bought.mako', extra_vars={'group': group})
    msg = EmailMessage(_('Group space bought'), text)
    msg.send(group)
Esempio n. 13
0
def group_request_email(group, user):
    """Send an email to administrators of a group, informing of a membership request."""
    text = render('/emails/group_request.mako', extra_vars={'group': group, 'user': user})
    msg = EmailMessage(_('Ututi group membership request'), text)
    msg.send(group.administrators)
Esempio n. 14
0
def send_email_confirmation_code(email, url):
    text = render('/emails/confirm_email.mako',
                  extra_vars={'link': url})

    msg = EmailMessage(_('Confirm your email for Ututi'), text, force=True)
    msg.send(email)