Esempio n. 1
0
 def vocab(self):
     ret = list()
     path = nodepath(self.model)
     count = self.references_tile.item_count
     slicesize = self.references_tile.slicesize
     pages = count / slicesize
     if count % slicesize != 0:
         pages += 1
     current = self.request.params.get('b_page', '0')
     params = {
         UX_IDENT: UX_FRONTEND,
         'submitter_came_from': submitter_came_from(self.request),
         'size': slicesize,
     }
     for i in range(pages):
         params['b_page'] = str(i)
         query = make_query(**params)
         url = make_url(self.request, path=path, query=query)
         ret.append({
             'page': '%i' % (i + 1),
             'current': current == str(i),
             'visible': True,
             'url': url,
         })
     return ret
Esempio n. 2
0
 def references(self, start, end):
     ret = list()
     for record in self.visible_references[start:end]:
         # ref title and path
         title = self.reference_title(record)
         path = self.reference_path(record)
         # case rendered in frontend
         if self.is_frontend:
             query = make_query(**{
                 UX_IDENT: UX_FRONTEND,
                 'submitter_came_from': submitter_came_from(self.request),
             })
             ref = self._make_reference(
                 title,
                 target=make_url(self.request, path=path, query=query),
                 overlay=self.reference_tile,
                 icon=self.icon,
                 path=self.reference_permalink(record)
             )
         # case rendered in backend
         else:
             ref = self._make_reference(
                 title,
                 target=make_url(self.request, path=path),
                 event='contextchanged:#layout',
                 icon=self.icon,
                 path='target'
             )
         ret.append(ref)
     return ret
Esempio n. 3
0
 def next(self, request):
     came_from_url = urllib2.unquote(request.get('authoring_came_from'))
     came_from_url += make_query(**{
         UX_IDENT: UX_FRONTEND,
         'submitter_came_from': submitter_came_from(self.request),
     })
     came_from_tile = request.get('came_from_tile')
     return [AjaxOverlay(action=came_from_tile, target=came_from_url)]
Esempio n. 4
0
 def next(self, request):
     came_from_url = urllib2.unquote(request.get('authoring_came_from'))
     came_from_url += make_query(**{
         UX_IDENT: UX_FRONTEND,
         'submitter_came_from': submitter_came_from(self.request),
     })
     came_from_tile = request.get('came_from_tile')
     root_url = make_url(self.request, node=self.model.root)
     return [AjaxOverlay(action=came_from_tile, target=came_from_url),
             AjaxEvent(root_url, 'datachanged', '#chronotope-map')]
Esempio n. 5
0
 def contents(self):
     url = submitter_came_from(self.request)
     if not url:
         query = make_query(**{UX_IDENT: UX_FRONTEND})
         url = make_url(self.request, node=self.model.root, query=query)
     return {
         'btn': 'default',
         'target': url,
         'overlay': 'submitter_contents',
         'icon': 'glyphicon glyphicon-th-list',
         'title': _('my_items', default=u'My Items'),
     }
Esempio n. 6
0
 def prepare(_next, self):
     _next(self)
     self.form['submitter_came_from'] = factory(
         'proxy',
         value=submitter_came_from(self.request),
     )
     self.form['authoring_came_from'] = factory(
         'proxy',
         value=self.request.params.get('authoring_came_from'),
     )
     self.form['came_from_tile'] = factory(
         'proxy',
         value=self.request.params.get('came_from_tile'),
     )
     if self.authenticated:
         return
     save_widget = self.form['controls']
     accept_terms_of_use = factory(
         'field:label:div:*accept_terms_of_use:error:help:checkbox',
         name='accept_terms_of_use',
         props={
             'label': _('accept_terms_of_use', default='Accept'),
             'help': _('accept_terms_of_use_help',
                       default='I have read the Terms of Use and agree to'),
             'label.class_add': 'col-sm-2',
             'div.class_add': 'col-sm-10',
             'error.position': 'after',
             'checkbox.class_add': 'accept_terms_of_use',
         },
         custom={
             'accept_terms_of_use': {
                 'extractors': [self.accept_terms_of_use]
             },
         },
     )
     self.form.insertbefore(accept_terms_of_use, save_widget)
     captcha_widget = factory(
         'field:label:div:error:recaptcha',
         name='captcha',
         props={
             'label': _('verify', default='Verify'),
             'public_key': get_recaptcha_public_key(self.model),
             'private_key': get_recaptcha_private_key(self.model),
             'lang': 'de',
             'theme': 'clean',
             'label.class_add': 'col-sm-2',
             'div.class_add': 'col-sm-10',
             'error.position': 'after',
         },
     )
     self.form.insertbefore(captcha_widget, save_widget)
Esempio n. 7
0
 def edit(self):
     if not self.can_edit:
         return None
     params = {
         UX_IDENT: UX_FRONTEND,
         'authoring_came_from': self.authoring_came_from,
         'submitter_came_from': submitter_came_from(self.request),
     }
     params.update(self.additional_editing_params)
     query = make_query(**params)
     url = make_url(self.request, node=self.model, query=query)
     return {
         'btn': 'default',
         'target': url,
         'overlay': 'overlayedit',
         'icon': 'glyphicon glyphicon-pencil',
         'title': _('edit', default=u'Edit'),
     }
Esempio n. 8
0
 def next(self, request):
     came_from_url = urllib2.unquote(request.get('authoring_came_from'))
     root_url = make_url(self.request, node=self.model.root)
     if not came_from_url:
         if request.get('action.{0}.cancel'.format(self.form_name)):
             return [AjaxOverlay(close=True)]
         query = make_query(**{
             UX_IDENT: UX_FRONTEND,
         })
         url = make_url(self.request, node=self.model, query=query)
         return [AjaxOverlay(action='location', target=url),
                 AjaxEvent(root_url, 'datachanged', '#chronotope-map')]
     came_from_url += make_query(**{
         UX_IDENT: UX_FRONTEND,
         'submitter_came_from': submitter_came_from(self.request),
     })
     came_from_tile = request.get('came_from_tile')
     return [AjaxOverlay(action=came_from_tile, target=came_from_url),
             AjaxEvent(root_url, 'datachanged', '#chronotope-map')]
Esempio n. 9
0
 def edit(self):
     if not self.can_edit:
         return None
     params = {
         UX_IDENT: UX_FRONTEND,
         'authoring_came_from': self.authoring_came_from,
         'submitter_came_from': submitter_came_from(self.request),
         'came_from_tile': 'location',
         'locationform.coordinates.lat': str(self.model.attrs['lat']),
         'locationform.coordinates.lon': str(self.model.attrs['lon']),
         'locationform.coordinates.zoom': str(15),
     }
     query = make_query(**params)
     url = make_url(self.request, node=self.model, query=query)
     return {
         'btn': 'default',
         'target': url,
         'overlay': 'overlayedit',
         'icon': 'glyphicon glyphicon-pencil',
         'title': _('edit', default=u'Edit'),
     }
Esempio n. 10
0
 def add_attachment(self):
     params = {
         UX_IDENT: UX_FRONTEND,
         'factory': 'attachment',
         'authoring_came_from': self.authoring_came_from,
         'submitter_came_from': submitter_came_from(self.request),
     }
     params.update(self.additional_adding_params)
     query = make_query(**params)
     url = make_url(
         self.request,
         node=self.model.root['attachments'],
         query=query
     )
     return {
         'btn': 'default',
         'target': url,
         'overlay': 'overlayadd',
         'icon': 'glyphicon glyphicon-file',
         'title': _('add_attachment', default=u'Add Attachment'),
     }