How to use the indico.util.string.to_unicode function in indico

To help you get started, weโ€™ve selected a few indico examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github indico / indico / indico / modules / groups / legacy.py View on Github external
def __init__(self, group_id):
        self.id = to_unicode(group_id).encode('utf-8')
github indico / indico / indico / modules / rb / event / controllers.py View on Github external
def _process(self):
        query = _session_block_query(self.event)
        result = [{'id': session_block.id,
                   'friendly_id': session_block.session.friendly_id,
                   'title': session_block.full_title,
                   'full_title': '#{}: {} ({})'.format(
                       session_block.session.friendly_id, session_block.full_title,
                       to_unicode(format_datetime(session_block.timetable_entry.start_dt)))}
                  for session_block in query]
        return jsonify(result)
github indico / indico / indico / MaKaC / participant.py View on Github external
def setStatusRefused(self, responsibleUser=None):
        if self._status != "added":
            return False
        old_status = self._status
        self._status = "refused"

        signals.event.participant_changed.send(self.getConference(), user=self._avatar, participant=self,
                                               old_status=old_status, action='removed')
        self.getConference().log(EventLogRealm.participants, EventLogKind.negative, u'Participants',
                                 u'Participant refused to attend: {}'.format(to_unicode(self.getName())),
                                 session.user, data=self.getParticipantData())
        return True
github indico / indico / indico / web / http_api / metadata / ical.py View on Github external
loc = to_unicode(loc)
    if fossil['roomFullname']:
        loc += ' ' + to_unicode(fossil['roomFullname'])
    event.add('location', loc)
    description = ''
    if fossil.get('speakers'):
        speakers = ('{} ({})'.format(speaker['fullName'].encode('utf-8'),
                                     speaker['affiliation'].encode('utf-8')) for speaker in fossil['speakers'])
        description += 'Speakers: {}\n'.format(', '.join(speakers))

    if fossil['description']:
        desc_text = fossil['description'].strip()
        if not desc_text:
            desc_text = '<p>'
        try:
            description += '{}\n\n{}'.format(to_unicode(html.fromstring(to_unicode(desc_text))
                                                        .text_content()).encode('utf-8'),
                                             fossil['url'].encode('utf-8'))
        except ParserError:
            # this happens e.g. if desc_text contains only a html comment
            description += fossil['url'].encode('utf-8')
    else:
        description += fossil['url']
    event.add('description', description)
    cal.add_component(event)
</p>
github indico / indico / indico / modules / rb / notifications / reservations.py View on Github external
def _get_email_subject(self, **mail_params):
        return u'{prefix}[{room}] {subject} {date} {suffix}'.format(
            prefix=to_unicode(mail_params.get('subject_prefix', '')),
            room=self.reservation.room.full_name,
            subject=to_unicode(mail_params.get('subject', '')),
            date=to_unicode(self.start_dt),
            suffix=to_unicode(mail_params.get('subject_suffix', ''))
        ).strip()
github indico / indico / indico / legacy / common / mail.py View on Github external
def sendAndLog(cls, notification, event, module=None, user=None, skipQueue=False):
        from indico.modules.events.logs import EventLogRealm, EventLogKind
        if isinstance(notification, dict):
            # Wrap a raw dictionary in a notification class
            from indico.legacy.webinterface.mail import GenericNotification
            notification = GenericNotification(notification)
        cls.send(notification, skipQueue=skipQueue)
        log_data = {
            u'content_type': to_unicode(notification.getContentType()),
            u'from': to_unicode(notification.getFromAddr()),
            u'to': map(to_unicode, notification.getToList()),
            u'cc': map(to_unicode, notification.getCCList()),
            u'bcc': map(to_unicode, notification.getBCCList()),
            u'subject': to_unicode(notification.getSubject()).strip(),
            u'body': to_unicode(notification.getBody()).strip()
        }
        summary = u'Sent email: {}'.format(log_data[u'subject'])
        event.log(EventLogRealm.emails, EventLogKind.other, to_unicode(module or u'Unknown'), summary, user,
                  type_=u'email', data=log_data)
github indico / indico / indico / MaKaC / webinterface / rh / categoryDisplay.py View on Github external
    @classmethod
    def setValues(cls, c, confData, notify=False):
        c.setTitle( confData["title"] )
        c.setDescription( confData["description"] )
        c.as_event.organizer_info = to_unicode(confData.get("orgText", ""))
        c.as_event.additional_info = to_unicode(confData.get("contactInfo", ""))
        c.as_event.keywords = confData["keywords"]
        c.setChairmanText( confData.get("chairText", "") )
        if "shortURLTag" in confData.keys():
            tag = to_unicode(confData["shortURLTag"]).strip()
            if tag:
                try:
                    UtilsConference.validateShortURL(tag, c.as_event)
                except ValueError, e:
                    raise FormValuesError(e.message)
                c.as_event.url_shortcut = tag
            else:
                c.as_event.url_shortcut = None
        #################################
        # Fermi timezone awareness      #
        #################################
github indico / indico / indico / core / notifications.py View on Github external
def _log_email(email, event, module, user):
    from indico.modules.events.logs import EventLogKind, EventLogRealm
    if not event:
        return None
    log_data = {
        'content_type': 'text/html' if email['html'] else 'text/plain',
        'from': email['from'],
        'to': sorted(email['to']),
        'cc': sorted(email['cc']),
        'bcc': sorted(email['bcc']),
        'subject': email['subject'],
        'body': email['body'].strip(),
        'state': 'pending',
        'sent_dt': None,
    }
    return event.log(EventLogRealm.emails, EventLogKind.other, to_unicode(module or 'Unknown'), log_data['subject'],
                     user, type_='email', data=log_data)
github indico / indico / indico / modules / users / legacy.py View on Github external
def setTimezone(self, tz):
        self.user.settings.set('timezone', to_unicode(tz))
github indico / indico / indico / legacy / pdfinterface / conference.py View on Github external
last_name_upper=False,
                                                                             abbrev_first_name=False)),
                                                      escape(c.affiliation)))
                    else:
                        conv.append(escape(c.full_name))

                conv = u'; '.join(conv)
                if conv:
                    conv = u'<font face="Times-Bold"><b>-{}: {}</b></font>'.format(_(u"Conveners"), conv)

                res.append(Paragraph('', self._styles["session_title"]))

                if self._ttPDFFormat.showDateCloseToSessions():
                    start_dt = to_unicode(format_datetime(sess_block.timetable_entry.start_dt, timezone=self._tz))
                else:
                    start_dt = to_unicode(format_time(sess_block.timetable_entry.start_dt, timezone=self._tz))

                sess_caption = u'<font face="Times-Bold">{}</font>'.format(escape(session_caption))
                text = u'<u>{}</u>{} ({}-{})'.format(
                    sess_caption, room, start_dt,
                    to_unicode(format_time(sess_block.timetable_entry.end_dt, timezone=self._tz)))

                p1 = Paragraph(text, self._styles["session_title"])
                if self._useColors():
                    ts = deepcopy(colorts)
                    ts.add('BACKGROUND', (0, 0), (0, -1), self._getSessionColor(sess_block))
                    p1 = Table([["", p1]], colWidths=[0.2 * cm, None], style=ts)

                res.append(p1)
                if self._ttPDFFormat.showTitleSessionTOC():
                    self._indexedFlowable[p1] = {'text': escape(sess_block.session.title.encode('utf-8')), 'level': 2}