def build_registration_data(self, reg):
     data = build_registration_api_data(reg)
     data['data_by_id'] = {}
     data['data_by_name'] = {}
     for field_id, item in reg.data_by_field.iteritems():
         data['data_by_id'][field_id] = item.friendly_data
     for item in reg.data:
         fieldname = slugify(item.field_data.field.title)
         fieldparent = slugify(item.field_data.field.parent.title)
         data['data_by_name']['{}_{}'.format(
             fieldparent, fieldname)] = item.friendly_data
     return data
Example #2
0
 def url(self):
     # explicit _external=False since offline site creation forces
     # _external=True if not specified and we want to be able to mangle
     # the generated urls into something suitable as filenames
     if self.is_user_link:
         return self.link_url
     elif (self.is_internal_link or self.is_plugin_link) and not self.default_data.endpoint:
         return None
     elif self.is_internal_link:
         data = self.default_data
         if data.static_site and isinstance(data.static_site, basestring) and g.get('static_site'):
             return data.static_site
         kwargs = {}
         if self.name == 'timetable':
             from indico.modules.events. layout import layout_settings
             if layout_settings.get(self.event_ref, 'timetable_by_room'):
                 kwargs['layout'] = 'room'
             if layout_settings.get(self.event_ref, 'timetable_detailed'):
                 start_date = self.event_ref.start_dt_local
                 kwargs['_anchor'] = start_date.strftime('%Y%m%d.detailed')
         return url_for(data.endpoint, self.event_ref, _external=False, **kwargs)
     elif self.is_plugin_link:
         from indico.core.plugins import url_for_plugin
         return url_for_plugin(self.default_data.endpoint, self.event_ref, _external=False)
     elif self.is_page:
         return url_for('event_pages.page_display', self.event_ref, page_id=self.page_id,
                        slug=slugify(self.title, fallback=None), _external=False)
     else:
         return None
Example #3
0
 def slug(self):
     return slugify(self.friendly_id, self.title, maxlen=30)
Example #4
0
 def locator(self):
     return dict(self.menu_entry.event.locator,
                 page_id=self.id,
                 slug=slugify(self.menu_entry.title, fallback=None))
Example #5
0
def test_slugify_lower(input, lower, output):
    assert slugify(input, lower=lower) == output
Example #6
0
def test_slugify(input, output):
    assert slugify(input) == output
Example #7
0
def test_slugify_maxlen():
    assert slugify('foo bar', maxlen=5) == 'foo-b'
Example #8
0
def test_slugify_args():
    assert slugify('foo', 123, 'bar') == 'foo-123-bar'
    assert slugify(u'm\xf6p'.encode('utf-8'), 123,
                   u'b\xe4r') == 'moep-123-baer'
Example #9
0
def test_slugify(input, output):
    assert slugify(input) == output
Example #10
0
def test_slugify_args():
    assert slugify('foo', 123, 'bar') == 'foo-123-bar'
    assert slugify('m\xf6p', 123, 'b\xe4r') == 'moep-123-baer'
Example #11
0
 def slug(self):
     return slugify('sc',
                    self.contribution.friendly_id,
                    self.friendly_id,
                    self.title,
                    maxlen=30)
Example #12
0
 def locator(self):
     return dict(self.menu_entry.event_new.locator,
                 page_id=self.id,
                 slug=slugify(self.menu_entry.title))
Example #13
0
 def locator(self):
     return dict(self.menu_entry.event_new.locator, page_id=self.id, slug=slugify(self.menu_entry.title))
Example #14
0
def test_slugify_args():
    assert slugify('foo', 123, 'bar') == 'foo-123-bar'
    assert slugify(u'm\xf6p'.encode('utf-8'), 123, u'b\xe4r') == 'moep-123-baer'
Example #15
0
 def locator(self):
     return dict(self.menu_entry.event.getLocator(), page_id=self.id, slug=slugify(self.menu_entry.title))
Example #16
0
 def url(self):
     # explicit _external=False since offline site creation forces
     # _external=True if not specified and we want to be able to mangle
     # the generated urls into something suitable as filenames
     if self.is_user_link:
         return self.link_url
     elif self.is_internal_link:
         data = self.default_data
         if data.static_site and isinstance(data.static_site, basestring) and ContextManager.get('offlineMode'):
             return data.static_site
         kwargs = {}
         if self.name == 'timetable':
             from indico.modules.events. layout import layout_settings
             if layout_settings.get(self.event, 'timetable_by_room'):
                 kwargs['ttLyt'] = 'room'
             if layout_settings.get(self.event, 'timetable_detailed'):
                 start_date = self.event.getSchedule().getAdjustedStartDate()
                 kwargs['_anchor'] = start_date.strftime('%Y%m%d.detailed')
         return url_for(data.endpoint, self.event, _external=False, **kwargs)
     elif self.is_plugin_link:
         from indico.core.plugins import url_for_plugin
         return url_for_plugin(self.default_data.endpoint, self.event, _external=False)
     elif self.is_page:
         return url_for('event_pages.page_display', self.event, page_id=self.page_id, slug=slugify(self.title),
                        _external=False)
     else:
         return None
Example #17
0
 def slug(self):
     return slugify(self.title, fallback=None)
Example #18
0
def test_slugify_maxlen():
    assert slugify('foo bar', maxlen=5) == 'foo-b'
Example #19
0
 def locator(self):
     return dict(self.menu_entry.event.getLocator(),
                 page_id=self.id,
                 slug=slugify(self.menu_entry.title))
Example #20
0
def test_slugify_lower(input, lower, output):
    assert slugify(input, lower=lower) == output
Example #21
0
 def slug(self):
     return slugify('b', self.id, self.session.title, self.title, maxlen=30)