Esempio n. 1
0
 def contact(self):
     """ Contact moderators of the meeting
     """
     recipients = []
     for userid in find_role_userids(self.context, ROLE_MODERATOR):
         user = self.api.get_user(userid)
         email = user.get_field_value('email')
         if email:
             recipients.append(email)
     if not recipients:
         for userid in find_authorized_userids(self.context,
                                               (MODERATE_MEETING, )):
             user = self.api.get_user(userid)
             email = user.get_field_value('email')
             if email:
                 recipients.append(email)
     schema = createSchema('ContactSchema').bind(context=self.context,
                                                 request=self.request,
                                                 api=self.api)
     form = Form(schema, buttons=(button_send, ))
     self.api.register_form_resources(form)
     post = self.request.POST
     if self.request.method == 'POST':
         controls = post.items()
         try:
             appstruct = form.validate(controls)
         except ValidationFailure, e:
             self.response['form'] = e.render()
             return self.response
         if appstruct.get('email', None):
             sender = appstruct['email']
             if self.api.user_profile:
                 sender += " <%s>" % self.api.user_profile.title
         else:
             sender = None
         response = {
             'api': self.api,
             'meeting': self.context,
             'name': appstruct['name'],
             'email': appstruct['email'],
             'subject': appstruct['subject'],
             'message': appstruct['message'],
         }
         body_html = render('templates/email/help_contact.pt',
                            response,
                            request=self.request)
         subject = "[%s] %s" % (self.context.title, appstruct['subject'])
         send_email(subject,
                    recipients,
                    body_html,
                    sender=sender,
                    request=self.request)
         self.api.flash_messages.add(_(u"Message sent to the moderators"))
         url = self.request.resource_url(self.context)
         return HTTPFound(location=url)
Esempio n. 2
0
 def send_success(self, appstruct):
     sender = appstruct['email'] and appstruct['email'] or "VoteIT <*****@*****.**>"
     response = {'api': self.api,
                 'meeting': self.api.meeting,
                 'name': appstruct['name'],
                 'email': appstruct['email'],
                 'subject': appstruct['subject'],
                 'message': appstruct['message'],
                 'meeting_title': appstruct.get('meeting_title', ''),}
     body_html = render('templates/email/support.pt', response, request = self.request)
     title = "%s %s" % (self.api.root.get_field_value('site_title', u"VoteIT"), self.api.translate(_(u"Support")))
     subject = "[%s] | %s" % (title, appstruct['subject'])
     support_email = self.api.root.get_field_value('support_email')
     send_email(subject, [support_email], body_html, sender = sender, request = self.request)
     self.api.flash_messages.add(_(u"Message sent"))
     return HTTPFound(location = self.request.resource_url(self.context))
Esempio n. 3
0
 def send(self, request, message = u""):
     if self.closed: #Just as a precaution
         return
     meeting = find_interface(self, IMeeting)
     html = render_view_action(self, request, 'email', 'invite_ticket', message = message)
     subject = _(u"Invitation to ${meeting_title}", mapping = {'meeting_title': meeting.title})
     if send_email(subject = subject, recipients = self.email, html = html, request = request, send_immediately = True):
         self.sent_dates.append(utcnow())
Esempio n. 4
0
 def contact(self):
     """ Contact moderators of the meeting
     """
     recipients = []
     for userid in find_role_userids(self.context, ROLE_MODERATOR):
         user = self.api.get_user(userid)
         email = user.get_field_value('email')
         if email:
             recipients.append(email)
     if not recipients:
         for userid in find_authorized_userids(self.context, (MODERATE_MEETING,)):
             user = self.api.get_user(userid)
             email = user.get_field_value('email')
             if email:
                 recipients.append(email)
     schema = createSchema('ContactSchema').bind(context = self.context, request = self.request, api = self.api)
     form = Form(schema, buttons=(button_send,))
     self.api.register_form_resources(form)
     post = self.request.POST
     if self.request.method == 'POST':
         controls = post.items()
         try:
             appstruct = form.validate(controls)
         except ValidationFailure, e:
             self.response['form'] = e.render()
             return self.response
         if appstruct.get('email', None):
             sender = appstruct['email']
             if self.api.user_profile:
                 sender += " <%s>" % self.api.user_profile.title
         else:
             sender = None
         response = {'api': self.api,
                     'meeting': self.context,
                     'name': appstruct['name'],
                     'email': appstruct['email'],
                     'subject': appstruct['subject'],
                     'message': appstruct['message'],}
         body_html = render('templates/email/help_contact.pt', response, request=self.request)
         subject = "[%s] %s" % (self.context.title, appstruct['subject'])
         send_email(subject, recipients, body_html, sender = sender, request = self.request)
         self.api.flash_messages.add(_(u"Message sent to the moderators"))
         url = self.request.resource_url(self.context)
         return HTTPFound(location = url)
Esempio n. 5
0
 def send_success(self, appstruct):
     if appstruct.get('email', None):
         sender = appstruct['email']
         if self.api.user_profile:
             sender += " <%s>" % self.api.user_profile.title
     else:
         sender = None
     response = {'api': self.api,
                 'meeting': self.api.meeting,
                 'name': appstruct['name'],
                 'email': appstruct['email'],
                 'subject': appstruct['subject'],
                 'message': appstruct['message'],
                 'meeting_title': appstruct.get('meeting_title', ''),}
     body_html = render('templates/email/help_contact.pt', response, request = self.request)
     subject = "[%s] %s" % (self.context.title, appstruct['subject'])
     recipients = self.get_recipients()
     send_email(subject, recipients, body_html, sender = sender, request = self.request)
     self.api.flash_messages.add(_(u"Message sent to the moderators"))
     url = self.request.resource_url(self.context)
     return HTTPFound(location = url)