Example #1
0
    def _process_POST(self):
        if User.has_rows():
            return redirect(url_for('misc.index'))
        setup_form = BootstrapForm(request.form)
        if not setup_form.validate():
            flash(_("Some fields are invalid. Please, correct them and submit the form again."), 'error')
            return redirect(url_for('bootstrap.index'))

        # Creating new user
        user = User()
        user.first_name = to_unicode(setup_form.first_name.data)
        user.last_name = to_unicode(setup_form.last_name.data)
        user.affiliation = to_unicode(setup_form.affiliation.data)
        user.email = to_unicode(setup_form.email.data)
        user.is_admin = True

        identity = Identity(provider='indico', identifier=setup_form.username.data, password=setup_form.password.data)
        user.identities.add(identity)

        db.session.add(user)
        db.session.flush()

        user.settings.set('timezone', Config.getInstance().getDefaultTimezone())
        user.settings.set('lang', to_unicode(setup_form.language.data))

        login_user(user, identity)
        full_name = user.full_name  # needed after the session closes

        transaction.commit()

        # Configuring server's settings
        minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
        minfo.setOrganisation(setup_form.affiliation.data)
        minfo.setLang(setup_form.language.data)

        message = get_template_module('bootstrap/flash_messages.html').bootstrap_success(name=full_name)
        flash(Markup(message), 'success')

        # Activate instance tracking
        if setup_form.enable_tracking.data:
            contact_name = setup_form.contact_name.data
            contact_email = setup_form.contact_email.data

            try:
                register_instance(contact_name, contact_email)
            except (HTTPError, ValueError) as err:
                message = get_template_module('bootstrap/flash_messages.html').community_error(err=err)
                category = 'error'
            except Timeout:
                message = get_template_module('bootstrap/flash_messages.html').community_timeout()
                category = 'error'
            except RequestException as exc:
                message = get_template_module('bootstrap/flash_messages.html').community_exception(exc=exc)
                category = 'error'
            else:
                message = get_template_module('bootstrap/flash_messages.html').community_success()
                category = 'success'
            flash(Markup(message), category)

        return redirect(url_for('misc.index'))
Example #2
0
def notify_payment_confirmation(registrant, amount):
    event = registrant.getConference()
    reg_form = registrant.getRegistrationForm()
    from_address = reg_form.getNotificationSender()
    currency = payment_event_settings.get(event, 'currency')

    # Send email to organizers
    notification = reg_form.getNotification()
    to_list = notification.getToList()
    cc_list = notification.getCCList()
    if to_list or cc_list:
        reg_page = url_for('event_mgmt.confModifRegistrants-modification', registrant, _external=True, _secure=True)
        tpl = get_template_module('payment/emails/payment_confirmation_organizers.txt', event=event,
                                  registrant=registrant, amount=amount, currency=currency, reg_page=reg_page)
        yield make_email(to_list, cc_list, from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body())

    # Send email to the registrant
    if reg_form.isSendPaidEmail():
        success_email_msg = payment_event_settings.get(event, 'success_email')
        params = {}
        if not registrant.getAvatar():
            params = {'registrantId': registrant.getId(), 'authkey': registrant.getRandomId()}
        reg_page = url_for('event.confRegistrationFormDisplay', event, _external=True, _secure=True, **params)
        tpl = get_template_module('payment/emails/payment_confirmation_registrant.txt', event=event,
                                  registrant=registrant, amount=amount, currency=currency,
                                  success_email_msg=success_email_msg, reg_page=reg_page)
        yield make_email(registrant.getEmail(), from_address=from_address, subject=tpl.get_subject(),
                         body=tpl.get_body())
Example #3
0
def notify_registration_modification(event, registrant):
    reg_form = registrant.getRegistrationForm()
    from_address = reg_form.getNotificationSender()
    reg_details = _get_reg_details(reg_form, registrant)

    # Send email to organizers
    notification = reg_form.getNotification()
    to_list = notification.getToList()
    cc_list = notification.getCCList()
    if to_list or cc_list:
        reg_page = url_for('event_mgmt.confModifRegistrants-modification', registrant, _external=True, _secure=True)
        tpl = get_template_module('events/registration/emails/registration_modification_organizers.html', event=event,
                                  registrant=registrant, reg_page=reg_page, reg_details=reg_details)
        yield make_email(to_list, cc_list, from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body(),
                         html=True)

    # Send email to the registrant
    if reg_form.isSendRegEmail():
        needs_to_pay = registrant.doPay() and payment_event_settings.get(event, 'enabled')
        params = {}
        if not registrant.getAvatar():
            params = {'registrantId': registrant.getId(), 'authkey': registrant.getRandomId()}
        reg_page = url_for('event.confRegistrationFormDisplay', event, _external=True, _secure=True, **params)
        tpl = get_template_module('events/registration/emails/registration_modification_registrant.html', event=event,
                                  registrant=registrant, payment_enabled=payment_event_settings.get(event, 'enabled'),
                                  reg_page=reg_page, needs_to_pay=needs_to_pay, reg_details=reg_details)

        yield make_email(registrant.getEmail(), from_address=from_address, subject=tpl.get_subject(),
                         body=tpl.get_body(), html=True)
Example #4
0
 def render_list(self, abstract=None):
     list_kwargs = self.get_list_kwargs()
     tpl = get_template_module('events/abstracts/management/_abstract_list.html')
     filtering_enabled = list_kwargs.pop('filtering_enabled')
     tpl_lists = get_template_module('events/management/_lists.html')
     filter_statistics = tpl_lists.render_displayed_entries_fragment(len(list_kwargs['abstracts']),
                                                                     list_kwargs['total_abstracts'])
     return {
         'html': tpl.render_abstract_list(**list_kwargs),
         'filtering_enabled': filtering_enabled,
         'filter_statistics': filter_statistics,
         'hide_abstract': abstract not in list_kwargs['abstracts'] if abstract else None
     }
Example #5
0
    def render_contribution_list(self):
        """Render the contribution list template components.

        :return: dict containing the list's entries, the fragment of
                 displayed entries and whether the contribution passed is displayed
                 in the results.
        """
        contrib_list_kwargs = self.get_list_kwargs()
        total_entries = contrib_list_kwargs.pop('total_entries')
        contribs = contrib_list_kwargs['contribs']
        tpl = get_template_module('events/contributions/display/_contribution_list.html')
        tpl_lists = get_template_module('events/management/_lists.html')
        return {'html': tpl.render_contribution_list(self.event, self.event.display_tzinfo, contribs, total_entries),
                'counter': tpl_lists.render_displayed_entries_fragment(len(contribs), total_entries)}
Example #6
0
    def render_contribution_list(self):
        """Render the contribution report template components.

        :return: dict containing the report's entries, the fragment of
                 displayed entries and whether the contrib passed is displayed
                 in the results.
        """
        contrib_report_kwargs = self.get_contrib_report_kwargs()
        total_entries = contrib_report_kwargs.pop('total_entries')
        contribs = contrib_report_kwargs['contribs']
        tpl = get_template_module('events/contributions/display/_contribution_list.html')
        tpl_reports = get_template_module('events/management/_reports.html')
        tz = timezone(DisplayTZ(session.user, self.report_event.as_legacy).getDisplayTZ())
        return {'html': tpl.render_contribution_list(self.report_event, tz, contribs),
                'counter': tpl_reports.render_displayed_entries_fragment(len(contribs), total_entries)}
Example #7
0
 def _process(self):
     user, identity = register_user(self.request.email, self.request.extra_emails, self.request.user_data,
                                    self.request.identity_data, self.request.settings)
     tpl = get_template_module('users/emails/registration_request_accepted.txt', user=user)
     send_email(make_email(self.request.email, template=tpl))
     flash(_('The request has been approved.'), 'success')
     return jsonify_data()
Example #8
0
 def send_submission_notification(self, submission):
     if not self.notifications_enabled:
         return
     template_module = get_template_module("events/surveys/emails/new_submission_email.txt", submission=submission)
     email = make_email(bcc_list=self.new_submission_emails, template=template_module)
     send_email(email, event=self.event, module="Surveys")
     logger.info("Sending submission notification for survey {}".format(self))
Example #9
0
File: util.py Project: fph/indico
def jsonify_form(form, fields=None, submit=None, back=None, back_url=None, back_button=True, disabled_until_change=True,
                 disabled_fields=(), form_header_kwargs=None, skip_labels=False):
    """Returns a json response containing a rendered WTForm.

    This ia shortcut to the ``simple_form`` jinja macro to avoid
    adding new templates that do nothing besides importing and
    calling this macro.

    :param form: A WTForms `Form` instance
    :param fields: A list of fields to be displayed on the form
    :param submit: The title of the submit button
    :param back: The title of the back button
    :param back_url: The URL the back button redirects to
    :param back_button: Whether to show a back button
    :param disabled_until_change: Whether to disable form submission
                                  until a field is changed
    :param disabled_fields: List of field names to disable
    :param form_header_kwargs: Keyword arguments passed to the
                               ``form_header`` macro
    :param skip_labels: Whether to show labels on the fields
    """
    if submit is None:
        submit = _('Save')
    if back is None:
        back = _('Cancel')
    if form_header_kwargs is None:
        form_header_kwargs = {}
    tpl = get_template_module('forms/_form.html')
    html = tpl.simple_form(form, fields=fields, submit=submit, back=back, back_url=back_url, back_button=back_button,
                           disabled_until_change=disabled_until_change, disabled_fields=disabled_fields,
                           form_header_kwargs=form_header_kwargs, skip_labels=skip_labels)
    return jsonify(html=html, js=_pop_injected_js())
Example #10
0
 def _process(self):
     form = build_review_form(self.paper.last_revision, self.type)
     if form.validate_on_submit():
         create_review(self.paper, self.type, session.user, **form.split_data)
         return jsonify_data(flash=False, html=render_paper_page(self.paper))
     tpl = get_template_module('events/reviews/forms.html')
     return jsonify(html=tpl.render_review_form(form, proposal=self.paper, group=self.type), js=_pop_injected_js())
Example #11
0
 def _process(self):
     form = build_review_form(review=self.review)
     if form.validate_on_submit():
         update_abstract_review(self.review, **form.split_data)
         return jsonify_data(flash=False, html=render_abstract_page(self.abstract, management=self.management))
     tpl = get_template_module('events/reviews/forms.html')
     return jsonify(html=tpl.render_review_form(form, review=self.review))
Example #12
0
 def _process(self):
     form = build_review_form(self.abstract, self.track)
     if form.validate_on_submit():
         create_abstract_review(self.abstract, self.track, session.user, **form.split_data)
         return jsonify_data(flash=False, html=render_abstract_page(self.abstract, management=self.management))
     tpl = get_template_module('events/reviews/forms.html')
     return jsonify(html=tpl.render_review_form(form, proposal=self.abstract, group=self.track))
Example #13
0
def _render_subcontribution_list(contrib):
    tpl = get_template_module('events/contributions/management/_subcontribution_list.html')
    subcontribs = (SubContribution.query.with_parent(contrib)
                   .options(undefer('attachment_count'))
                   .order_by(SubContribution.position)
                   .all())
    return tpl.render_subcontribution_list(contrib.event, contrib, subcontribs)
Example #14
0
 def _process(self):
     form = AbstractCommentForm(abstract=self.abstract, user=session.user)
     if form.validate_on_submit():
         create_abstract_comment(self.abstract, form.data)
         return jsonify_data(flash=False, html=render_abstract_page(self.abstract, management=self.management))
     tpl = get_template_module('events/reviews/forms.html')
     return jsonify(html=tpl.render_comment_form(form, proposal=self.abstract))
Example #15
0
 def send_submission_notification(self, submission):
     if not self.notifications_enabled:
         return
     template_module = get_template_module('events/surveys/emails/new_submission_email.txt', submission=submission)
     email = make_email(bcc_list=self.new_submission_emails, template=template_module)
     send_email(email, event=self.event_new, module='Surveys')
     logger.info('Sending submission notification for survey %s', self)
Example #16
0
def _render_template_list(target, event=None):
    tpl = get_template_module('designer/_list.html')
    default_template = get_default_template_on_category(target) if isinstance(target, Category) else None
    not_deletable = get_not_deletable_templates(target)
    return tpl.render_template_list(target.designer_templates, target, event=event, default_template=default_template,
                                    inherited_templates=get_inherited_templates(target),
                                    not_deletable_templates=not_deletable)
Example #17
0
def _registered(user, identity, from_moderation, **kwargs):
    from indico.modules.users.util import get_admin_emails
    if (from_moderation or identity is None or identity.provider != 'indico' or
            not user_management_settings.get('notify_account_creation')):
        return
    tpl = get_template_module('users/emails/profile_registered_admins.txt', user=user)
    send_email(make_email(get_admin_emails(), template=tpl))
Example #18
0
def get_base_ical_parameters(user, event, detail, session_=None):
    """Returns a dict of all parameters expected by iCal template"""

    from indico.web.http_api.util import generate_public_auth_request

    api_mode = api_settings.get('security_mode')
    persistent_allowed = api_settings.get('allow_persistent')
    api_key = user.api_key if user else None
    persistent_user_enabled = api_key.is_persistent_allowed if api_key else None
    tpl = get_template_module('api/_messages.html')
    persistent_agreement = tpl.get_ical_persistent_msg()
    if session_:
        path = '/export/event/{0}/session/{1}.ics'.format(event.id, session_.id)
    else:
        path = '/export/event/{0}.ics'.format(event.id)
    top_urls = generate_public_auth_request(api_key, path)
    urls = generate_public_auth_request(api_key, path, {'detail': detail})
    request_urls = {
        'publicRequestURL': top_urls['publicRequestURL'],
        'authRequestURL': top_urls['authRequestURL'],
        'publicRequestDetailedURL': urls['publicRequestURL'],
        'authRequestDetailedURL': urls['authRequestURL']
    }

    return {'api_mode': api_mode, 'api_key': api_key, 'persistent_allowed': persistent_allowed,
            'persistent_user_enabled': persistent_user_enabled, 'api_active': api_key is not None,
            'api_key_user_agreement': tpl.get_ical_api_key_msg(), 'api_persistent_user_agreement': persistent_agreement,
            'user_logged': user is not None, 'request_urls': request_urls}
Example #19
0
 def _sendReport(self):
     cfg = Config.getInstance()
     data = json.loads(self._msg)
     template = get_template_module('emails/error_report.txt', comment=self._comments, traceback=data['traceback'],
                                    request_info=pformat(data['request_info']),
                                    server_name=url_parse(cfg.getBaseURL()).netloc)
     send_email(make_email(cfg.getSupportEmail(), reply_address=self._userMail, template=template), skip_queue=True)
Example #20
0
def notify_event_creation(event, occurrences=None):
    """Send email notifications when a new Event is created

    :param event: The `Event` that has been created.
    :param occurrences: A list of event occurrences in case of a
                        series of events.  If specified, the links
                        and dates/times are only taken from the
                        events in this list.
    """
    emails = set()
    query = (event.category.chain_query.
             filter(Category.notify_managers | (Category.event_creation_notification_emails != []))
             .options(joinedload('acl_entries')))
    for cat in query:
        emails.update(cat.event_creation_notification_emails)
        if cat.notify_managers:
            for manager in cat.get_manager_list():
                if manager.is_single_person:
                    emails.add(manager.email)
                elif manager.is_group:
                    emails.update(x.email for x in manager.get_members())

    if emails:
        template = get_template_module('events/emails/event_creation.txt', event=event, occurrences=occurrences)
        send_email(make_email(bcc_list=emails, template=template))
Example #21
0
def notify_comment(person, paper, comment, submitter):
    event = paper.event
    receiver_name = person.first_name or 'user'
    template = get_template_module('events/papers/emails/comment.html', event=event, receiver=receiver_name,
                                   contribution=paper.contribution, comment=comment, submitter=submitter)
    email = make_email(to_list=person.email, template=template, html=True)
    send_email(email, event=event, module='Papers', user=session.user)
Example #22
0
def notify_invitation(invitation, email_subject, email_body, from_address):
    """Send a notification about a new registration invitation."""
    email_body = replace_placeholders('registration-invitation-email', email_body, invitation=invitation)
    email_subject = replace_placeholders('registration-invitation-email', email_subject, invitation=invitation)
    template = get_template_module('emails/custom.html', subject=email_subject, body=email_body)
    email = make_email(invitation.email, from_address=from_address, template=template, html=True)
    send_email(email, invitation.registration_form.event, 'Registration', session.user)
Example #23
0
    def getVars( self ):
        from indico.web.http_api.util import generate_public_auth_request

        vars = WHeader.getVars( self )
        vars["categurl"] = self._conf.as_event.category.url

        vars["conf"] = vars["target"] = self._conf

        vars["imgLogo"] = Config.getInstance().getSystemIconURL("miniLogo")
        vars["MaKaCHomeURL"] = self._conf.as_event.category.url

        # Default values to avoid NameError while executing the template
        styles = theme_settings.get_themes_for("conference")

        vars["viewoptions"] = [{'id': theme_id, 'name': data['title']}
                               for theme_id, data in sorted(styles.viewitems(), key=lambda x: x[1]['title'])]
        vars["SelectedStyle"] = ""
        vars["pdfURL"] = ""
        vars["displayURL"] = str(urlHandlers.UHConferenceOtherViews.getURL(self._conf))

        # Setting the buttons that will be displayed in the header menu
        vars["showFilterButton"] = False
        vars["showMoreButton"] = True
        vars["showExportToICal"] = True
        vars["showExportToPDF"] = False
        vars["showDLMaterial"] = True
        vars["showLayout"] = True

        vars["displayNavigationBar"] = layout_settings.get(self._conf, 'show_nav_bar')

        # This is basically the same WICalExportBase, but we need some extra
        # logic in order to have the detailed URLs
        apiMode = api_settings.get('security_mode')

        vars["icsIconURL"] = str(Config.getInstance().getSystemIconURL("ical_grey"))
        vars["apiMode"] = apiMode
        vars["signingEnabled"] = apiMode in {APIMode.SIGNED, APIMode.ONLYKEY_SIGNED, APIMode.ALL_SIGNED}
        vars["persistentAllowed"] = api_settings.get('allow_persistent')
        user = self._aw.getUser()
        apiKey = user.api_key if user else None

        topURLs = generate_public_auth_request(apiKey, '/export/event/%s.ics' % self._conf.getId())
        urls = generate_public_auth_request(apiKey, '/export/event/%s.ics' % self._conf.getId(),
                                            {'detail': 'contributions'})

        vars["requestURLs"] = {
            'publicRequestURL': topURLs["publicRequestURL"],
            'authRequestURL':  topURLs["authRequestURL"],
            'publicRequestDetailedURL': urls["publicRequestURL"],
            'authRequestDetailedURL':  urls["authRequestURL"]
        }

        vars["persistentUserEnabled"] = apiKey.is_persistent_allowed if apiKey else False
        vars["apiActive"] = apiKey is not None
        vars["userLogged"] = user is not None
        tpl = get_template_module('api/_messages.html')
        vars['apiKeyUserAgreement'] = tpl.get_ical_api_key_msg()
        vars['apiPersistentUserAgreement'] = tpl.get_ical_persistent_msg()

        return vars
Example #24
0
def render_session_bar(protected_object=None, local_tz=None, force_local_tz=False):
    protection_disclaimers = {
        'network': legal_settings.get('network_protected_disclaimer'),
        'restricted': legal_settings.get('restricted_disclaimer')
    }
    default_tz = config.DEFAULT_TIMEZONE
    if session.user:
        user_tz = session.user.settings.get('timezone', default_tz)
        if session.timezone == 'LOCAL':
            tz_mode = 'local'
        elif session.timezone == user_tz:
            tz_mode = 'user'
        else:
            tz_mode = 'custom'
    else:
        user_tz = None
        tz_mode = 'local' if session.timezone == 'LOCAL' else 'custom'
    active_tz = _get_timezone_display(local_tz, session.timezone, force_local_tz)
    timezones = common_timezones
    if active_tz not in common_timezones_set:
        timezones = list(common_timezones) + [active_tz]
    timezone_data = {
        'disabled': force_local_tz,
        'user_tz': user_tz,
        'active_tz': active_tz,
        'tz_mode': tz_mode,
        'timezones': timezones,
    }
    tpl = get_template_module('_session_bar.html')
    rv = tpl.render_session_bar(protected_object=protected_object,
                                protection_disclaimers=protection_disclaimers,
                                timezone_data=timezone_data,
                                languages=get_all_locales())
    return Markup(rv)
Example #25
0
    def __init__(self, *args, **kwargs):
        self.lightweight = kwargs.pop('lightweight', self.default_options['lightweight'])

        config = Config.getInstance()
        max_file_size = kwargs.pop('max_file_size', None)
        if max_file_size is None:
            max_file_size = min(config.getMaxUploadFileSize() or 10240,
                                config.getMaxUploadFilesTotalSize() or 10240)  # in MB
        self.allow_multiple_files = kwargs.pop('multiple_files', self.default_options['multiple_files'])
        self.widget_options = {
            'url': kwargs.pop('post_url', None),
            'uploadMultiple': self.allow_multiple_files,
            'maxFilesize': max_file_size,
            'maxFiles': kwargs.pop('max_files', self.default_options['max_files']) if self.allow_multiple_files else 1,
            'addRemoveLinks': kwargs.pop('add_remove_links', self.default_options['add_remove_links']),
            'acceptedFiles': kwargs.pop('accepted_file_types', None),
            'parallelUploads': kwargs.pop('max_files', self.default_options['max_files']),
            'handleFlashes': kwargs.pop('handle_flashes', self.default_options['handle_flashes'])
        }

        if self.lightweight:
            tpl = get_template_module('forms/_dropzone_themes.html')
            self.widget_options['previewTemplate'] = tpl.thin_preview_template()
            self.widget_options['dictRemoveFile'] = tpl.remove_icon()

        super(FileField, self).__init__(*args, **kwargs)
        self.widget_options['paramName'] = self.name
Example #26
0
 def _process(self):
     form = build_review_form(review=self.review)
     if form.validate_on_submit():
         update_review(self.review, **form.split_data)
         return jsonify_data(flash=False, html=render_paper_page(self.paper))
     tpl = get_template_module('events/reviews/forms.html')
     return jsonify(html=tpl.render_review_form(form, review=self.review), js=_pop_injected_js())
Example #27
0
 def _send_confirmation(self, email):
     token_storage = GenericCache('confirm-email')
     data = {'email': email, 'user_id': self.user.id}
     token = make_unique_token(lambda t: not token_storage.get(t))
     token_storage.set(token, data, 24 * 3600)
     send_email(make_email(email, template=get_template_module('users/emails/verify_email.txt',
                                                               user=self.user, email=email, token=token)))
Example #28
0
 def _process(self):
     form = EventLocationForm(obj=self.event_new)
     if form.validate_on_submit():
         update_event(self.event_new, form.data)
         flash(_('The location for the event has been updated'))
         tpl = get_template_module('events/management/_event_location.html')
         return jsonify_data(html=tpl.render_event_location_info(self.event_new.location_data))
     return jsonify_form(form)
Example #29
0
 def render_list(self):
     reg_list_kwargs = self.get_list_kwargs()
     tpl = get_template_module('events/registration/management/_reglist.html')
     filtering_enabled = reg_list_kwargs.pop('filtering_enabled')
     return {
         'html': tpl.render_registration_list(**reg_list_kwargs),
         'filtering_enabled': filtering_enabled
     }
Example #30
0
 def _process(self):
     form = EventPersonForm(obj=FormDefaults(self.person, skip_attrs={'title'}, title=self.person._title))
     if form.validate_on_submit():
         update_person(self.person, form.data)
         person_data = self.get_persons()[self.person.email or self.person.id]
         tpl = get_template_module('events/persons/management/_person_list_row.html')
         return jsonify_data(html=tpl.render_person_row(person_data))
     return jsonify_form(form)
Example #31
0
 def _process(self):
     form = _make_theme_settings_form(self.event, request.args['theme'])
     if not form:
         return jsonify()
     tpl = get_template_module('forms/_form.html')
     return jsonify(html=tpl.form_rows(form), js=_pop_injected_js())
Example #32
0
def _render_track_list(event):
    list_items = event.get_sorted_tracks()
    tpl = get_template_module('events/tracks/_track_list.html',
                              event=event,
                              list_items=list_items)
    return tpl.render_list(event, list_items)
Example #33
0
def notify_static_site_success(static_site):
    template = get_template_module('events/static/emails/download_notification_email.txt',
                                   user=static_site.creator, event=static_site.event,
                                   link=url_for('static_site.download', static_site, _external=True))
    return make_email({static_site.creator.email}, template=template, html=False)
Example #34
0
    def _process_POST(self):
        if User.query.filter_by(is_system=False).has_rows():
            return redirect(url_for_index())
        setup_form = BootstrapForm(request.form)
        if not setup_form.validate():
            flash(
                _("Some fields are invalid. Please, correct them and submit the form again."
                  ), 'error')
            return redirect(url_for('bootstrap.index'))

        # Creating new user
        user = User()
        user.first_name = to_unicode(setup_form.first_name.data)
        user.last_name = to_unicode(setup_form.last_name.data)
        user.affiliation = to_unicode(setup_form.affiliation.data)
        user.email = to_unicode(setup_form.email.data)
        user.is_admin = True

        identity = Identity(provider='indico',
                            identifier=setup_form.username.data,
                            password=setup_form.password.data)
        user.identities.add(identity)

        db.session.add(user)
        db.session.flush()

        user.settings.set('timezone', config.DEFAULT_TIMEZONE)
        user.settings.set('lang', session.lang or config.DEFAULT_LOCALE)

        login_user(user, identity)
        full_name = user.full_name  # needed after the session closes

        db.session.commit()

        # Configuring server's settings
        core_settings.set('site_organization', setup_form.affiliation.data)

        message = get_template_module(
            'bootstrap/flash_messages.html').bootstrap_success(name=full_name)
        flash(Markup(message), 'success')

        # Activate instance tracking
        if setup_form.enable_tracking.data:
            contact_name = setup_form.contact_name.data
            contact_email = setup_form.contact_email.data

            try:
                register_instance(contact_name, contact_email)
            except (HTTPError, ValueError) as err:
                message = get_template_module(
                    'bootstrap/flash_messages.html').community_error(err=err)
                category = 'error'
            except Timeout:
                message = get_template_module(
                    'bootstrap/flash_messages.html').community_timeout()
                category = 'error'
            except RequestException as exc:
                message = get_template_module('bootstrap/flash_messages.html'
                                              ).community_exception(exc=exc)
                category = 'error'
            else:
                message = get_template_module(
                    'bootstrap/flash_messages.html').community_success()
                category = 'success'
            flash(Markup(message), category)

        return redirect(url_for_index())
Example #35
0
def _render_teplate_list(event):
    tpl = get_template_module('events/papers/management/_templates.html')
    return jsonify_data(html=tpl.render_template_list(event))
Example #36
0
def _render_invitation_list(regform):
    tpl = get_template_module(
        'events/registration/management/_invitation_list.html')
    return tpl.render_invitation_list(_query_invitation_list(regform))
Example #37
0
def _render_menu_entry(entry):
    tpl = get_template_module('events/layout/_menu.html')
    return tpl.menu_entry(entry=entry)
Example #38
0
 def render_settings_box(self):
     tpl = get_template_module('events/management/_settings.html')
     assert self.section_name
     return tpl.render_event_settings(self.event_new,
                                      section=self.section_name,
                                      with_container=False)
Example #39
0
 def _process(self):
     events_by_month = self.group_by_month(self.events)
     tpl = get_template_module('categories/display/event_list.html')
     html = tpl.event_list_block(events_by_month=events_by_month, format_event_date=self.format_event_date,
                                 is_recent=self.is_recent, happening_now=self.happening_now)
     return jsonify_data(flash=False, html=html)
Example #40
0
def _render_registration_details(registration):
    event = registration.registration_form.event
    tpl = get_template_module('events/registration/management/_registration_details.html')
    return tpl.render_registration_details(registration=registration, payment_enabled=event.has_feature('payment'))
Example #41
0
def _render_role(role, collapsed=True):
    tpl = get_template_module('events/roles/_roles.html')
    return tpl.render_role(role, collapsed=collapsed)
Example #42
0
def _render_roles(event):
    tpl = get_template_module('events/roles/_roles.html')
    return tpl.render_roles(_get_roles(event))
Example #43
0
def render_session_type_row(session_type):
    template = get_template_module('events/sessions/management/_types_table.html')
    return template.types_table_row(session_type=session_type)
Example #44
0
    def getVars(self):
        from indico.web.http_api.util import generate_public_auth_request

        vars = WHeader.getVars(self)
        vars["categurl"] = self._conf.as_event.category.url

        vars["conf"] = vars["target"] = self._conf

        vars["imgLogo"] = Config.getInstance().getSystemIconURL("miniLogo")
        vars["MaKaCHomeURL"] = self._conf.as_event.category.url

        # Default values to avoid NameError while executing the template
        styles = theme_settings.get_themes_for("conference")

        vars["viewoptions"] = [{
            'id': theme_id,
            'name': data['title']
        } for theme_id, data in sorted(styles.viewitems(),
                                       key=lambda x: x[1]['title'])]
        vars["SelectedStyle"] = ""
        vars["pdfURL"] = ""
        vars["displayURL"] = str(
            urlHandlers.UHConferenceOtherViews.getURL(self._conf))

        # Setting the buttons that will be displayed in the header menu
        vars["showFilterButton"] = False
        vars["showMoreButton"] = True
        vars["showExportToICal"] = True
        vars["showExportToPDF"] = False
        vars["showDLMaterial"] = True
        vars["showLayout"] = True

        vars["displayNavigationBar"] = layout_settings.get(
            self._conf, 'show_nav_bar')

        # This is basically the same WICalExportBase, but we need some extra
        # logic in order to have the detailed URLs
        apiMode = api_settings.get('security_mode')

        vars["icsIconURL"] = str(
            Config.getInstance().getSystemIconURL("ical_grey"))
        vars["apiMode"] = apiMode
        vars["signingEnabled"] = apiMode in {
            APIMode.SIGNED, APIMode.ONLYKEY_SIGNED, APIMode.ALL_SIGNED
        }
        vars["persistentAllowed"] = api_settings.get('allow_persistent')
        user = self._aw.getUser()
        apiKey = user.api_key if user else None

        topURLs = generate_public_auth_request(
            apiKey, '/export/event/%s.ics' % self._conf.getId())
        urls = generate_public_auth_request(
            apiKey, '/export/event/%s.ics' % self._conf.getId(),
            {'detail': 'contributions'})

        vars["requestURLs"] = {
            'publicRequestURL': topURLs["publicRequestURL"],
            'authRequestURL': topURLs["authRequestURL"],
            'publicRequestDetailedURL': urls["publicRequestURL"],
            'authRequestDetailedURL': urls["authRequestURL"]
        }

        vars[
            "persistentUserEnabled"] = apiKey.is_persistent_allowed if apiKey else False
        vars["apiActive"] = apiKey is not None
        vars["userLogged"] = user is not None
        tpl = get_template_module('api/_messages.html')
        vars['apiKeyUserAgreement'] = tpl.get_ical_api_key_msg()
        vars['apiPersistentUserAgreement'] = tpl.get_ical_persistent_msg()

        return vars
Example #45
0
def _render_menu_entries(event, connect_menu=False):
    tpl = get_template_module('events/layout/_menu.html')
    return tpl.menu_entries(menu_entries_for_event(event),
                            connect_menu=connect_menu)
Example #46
0
 def _process(self):
     provider = _get_provider(request.view_args['provider'], False)
     form = provider.login_form()
     template_module = get_template_module('auth/_login_form.html')
     return jsonify(success=True, html=template_module.login_form(provider, form))
Example #47
0
def _render_attachment_list(linked_object):
    tpl = get_template_module('attachments/_attachments.html')
    return tpl.render_attachments(attachments=get_attached_items(linked_object), linked_object=linked_object)
Example #48
0
def notify_about_finishing_bookings(user, reservations):
    tpl = get_template_module(
        'rb/emails/reservations/reminders/finishing_bookings.html',
        reservations=reservations,
        user=user)
    return make_email(to_list={user.email}, template=tpl, html=True)
Example #49
0
def _render_notification_list(event, flash=True):
    tpl = get_template_module(
        'events/abstracts/management/_notification_tpl_list.html')
    return jsonify_data(html=tpl.render_notification_list(
        event, **_get_rules_fields(event)),
                        flash=flash)
Example #50
0
def get_plugin_template_module(template_name, **context):
    """Like :func:`~indico.web.flask.templating.get_template_module`, but using plugin templates"""
    template_name = '{}:{}'.format(current_plugin.name, template_name)
    return get_template_module(template_name, **context)
Example #51
0
 def _process(self):
     users = [User.get(int(id_)) for id_ in request.form.getlist('user_id')]
     self.user.favorite_users |= set(filter(None, users))
     tpl = get_template_module('users/_favorites.html')
     return jsonify(success=True, users=[serialize_user(user) for user in users],
                    html=tpl.favorite_users_list(self.user))
Example #52
0
def _render_event_label_list():
    tpl = get_template_module('events/admin/_event_label_list.html')
    return tpl.render_event_label_list(_get_all_event_labels())
Example #53
0
def _render_session_list(event):
    tpl = get_template_module('events/sessions/management/_session_list.html')
    return tpl.render_session_list(event, **_get_session_list_args(event))
Example #54
0
def render_event_management_header_right(event):
    tpl = get_template_module('events/management/_management_frame.html')
    return tpl.render_event_management_header_right(event=event, event_types=[(et.name, et.title) for et in EventType])
Example #55
0
def _render_reference_type_list():
    tpl = get_template_module('events/admin/_reference_type_list.html')
    return tpl.render_reference_type_list(_get_all_reference_types())
Example #56
0
 def _process(self):
     tpl = get_template_module('attachments/_management_info_column.html')
     return jsonify(html=tpl.render_attachment_info(self.object))
Example #57
0
def notify_upcoming_occurrences(user, occurrences):
    tpl = get_template_module(
        'rb/emails/reservations/reminders/upcoming_occurrence.html',
        occurrences=occurrences,
        user=user)
    return make_email(to_list={user.email}, template=tpl, html=True)
Example #58
0
def contribution_type_row(contrib_type):
    template = get_template_module('events/contributions/management/_types_table.html')
    html = template.types_table_row(contrib_type=contrib_type)
    return jsonify_data(html_row=html, flash=False)
Example #59
0
 def _render_ongoing_events(self, ongoing_events):
     template = get_template_module(
         'categories/display/_calendar_ongoing_events.html')
     return template.render_ongoing_events(ongoing_events,
                                           self.category.display_tzinfo)
Example #60
0
 def _process(self):
     db.session.delete(self.request)
     tpl = get_template_module('users/emails/registration_request_rejected.txt', req=self.request)
     send_email(make_email(self.request.email, template=tpl))
     flash(_('The request has been rejected.'), 'success')
     return jsonify_data()