Пример #1
0
def send_comment_notification(comment, notify_author=False):
    """
    Send a comment notification mail to all users related to the comment's
    proposal except for the author of the comment unless notify_author=True
    is passed.
    """
    proposal = comment.proposal
    current_user = comment.author
    if notify_author:
        current_user = None
    # WARNING: We cannot use `can_see_proposal_author` here, because we
    #          write a BCC mail to all involved reviewers and there will
    #          probably be at least one not allowed to see the author
    hide_author = conference_models.current_conference().anonymize_proposal_author and\
        is_proposal_author(comment.author, proposal)
    body = render_to_string('reviews/emails/comment_notification.txt', {
        'comment': comment,
        'proposal': proposal,
        'hide_author': hide_author,
        'site': Site.objects.get_current(),
        'proposal_url': reverse('reviews-proposal-details', kwargs={'pk': proposal.pk}),
    })
    if hide_author:
        subject = _("[REVIEW] The author has commented on \"%(title)s\"")
    else:
        subject = _("[REVIEW] %(author)s commented on \"%(title)s\"")
    msg = EmailMessage(subject=subject % {
            'author': account_utils.get_display_name(comment.author),
            'title': proposal.title},
        bcc=[u.email for u in get_people_to_notify(proposal, current_user)
             if has_valid_mailaddr(u)],
        body=body)
    msg.send()
Пример #2
0
def send_proposal_update_notification(version, notify_author=False):
    """
    Send a version notification mail to all users related to the version's
    proposal except for the author of the version unless notify_author=True
    is passed.
    """
    proposal = version.original
    current_user = version.creator
    if notify_author:
        current_user = None
    hide_author = conference_models.current_conference().anonymize_proposal_author and\
        is_proposal_author(current_user, proposal)
    body = render_to_string('reviews/emails/version_notification.txt', {
        'version': version,
        'proposal': proposal,
        'site': Site.objects.get_current(),
        'hide_author': hide_author,
        'proposal_url': reverse('reviews-proposal-details', kwargs={'pk': proposal.pk}),
    })
    if hide_author:
        subject = _("[REVIEW] The author updated %(title)s")
    else:
        subject = _("[REVIEW] %(author)s updated %(title)s")
    msg = EmailMessage(subject=subject % {
            'author': account_utils.get_display_name(version.creator),
            'title': proposal.title},
        bcc=[u.email for u in get_people_to_notify(proposal, current_user)],
        body=body)
    msg.send()
Пример #3
0
 def _export_speaker(self, fp, xf, user):
     profile = user.profile
     with xf.element('speaker', id=force_text(user.id)):
         with xf.element('name'):
             name = user.profile.full_name or get_display_name(user)
             xf.write(name, pretty_print=self.pretty)
         with xf.element('profile'):
             xf.write(self.base_url + reverse('account_profile',
                                              kwargs={'uid': user.id}), pretty_print=self.pretty)
         with xf.element('description'):
             xf.write(user.profile.short_info, pretty_print=self.pretty)
         with xf.element('image'):
             if profile.avatar:
                 avatar_url = self.base_url + profile.avatar.url
                 xf.write(avatar_url, pretty_print=self.pretty)
             if self.export_avatars:
                 filename, ext = os.path.splitext(profile.avatar.file.name)
                 dest = os.path.join(self.avatar_dir, str(user.id)) + ext
                 shutil.copy(profile.avatar.file.name, dest)
Пример #4
0
def send_proposal_update_notification(version, notify_author=False):
    """
    Send a version notification mail to all users related to the version's
    proposal except for the author of the version unless notify_author=True
    is passed.
    """
    proposal = version.original
    current_user = version.creator
    if notify_author:
        current_user = None
    hide_author = conference_models.current_conference().anonymize_proposal_author and\
        is_proposal_author(current_user, proposal)
    body = render_to_string(
        'reviews/emails/version_notification.txt', {
            'version':
            version,
            'proposal':
            proposal,
            'site':
            Site.objects.get_current(),
            'hide_author':
            hide_author,
            'proposal_url':
            reverse('reviews-proposal-details', kwargs={'pk': proposal.pk}),
        })
    if hide_author:
        subject = _("[REVIEW] The author updated %(title)s")
    else:
        subject = _("[REVIEW] %(author)s updated %(title)s")
    msg = EmailMessage(
        subject=subject % {
            'author': account_utils.get_display_name(version.creator),
            'title': proposal.title
        },
        bcc=[u.email for u in get_people_to_notify(proposal, current_user)],
        body=body)
    msg.send()
Пример #5
0
 def __unicode__(self):
     return account_utils.get_display_name(self.user)
Пример #6
0
 def get_name(self, instance):
     return account_utils.get_display_name(instance.user)
Пример #7
0
 def _create_event_from_session(self, session, location):
     element = etree.Element('event', id=unicode(session.id))
     etree.SubElement(element, 'title').text = session.title
     if session.track:
         etree.SubElement(element, 'track').text = session.track.name
     if session.start:
         etree.SubElement(element, 'date').text = self._format_datetime(session.start)
         etree.SubElement(element, 'start').text = self._format_time(session.start)
         etree.SubElement(element, 'duration').text = self._calculate_event_duration(session)
     recording_element = etree.SubElement(element, 'recording')
     etree.SubElement(recording_element, 'license')
     etree.SubElement(recording_element, 'optout').text = unicode(not session.accept_recording).lower()
     etree.SubElement(element, 'room').text = location.name
     etree.SubElement(element, 'language').text = session.language
     etree.SubElement(element, 'abstract').text = session.abstract
     etree.SubElement(element, 'description').text = session.description
     if session.kind:
         etree.SubElement(element, 'type').text = 'workshop' if session.kind.slug == 'training' else 'lecture'
     persons_element = etree.SubElement(element, 'persons')
     if session.speaker:
         etree.SubElement(persons_element, 'person', id=unicode(session.speaker.user.pk)).text = get_display_name(session.speaker.user)
     for speaker in session.additional_speakers.all():
         etree.SubElement(persons_element, 'person', id=unicode(speaker.user.pk)).text = get_display_name(speaker.user)
     return element
Пример #8
0
 def __unicode__(self):
     return account_utils.get_display_name(self.user)
Пример #9
0
 def get_name(self, instance):
     return account_utils.get_display_name(instance.user)