self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_result}) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs( self.request, batch, user) if filter_form: result = merge_dicts( {'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) values = {'bodies': result_body, 'batch': batch, 'filter_body': filter_body, 'sort_body': sort_body } body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} return result DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeIdeasToExamine: SeeIdeasToExamineView}) FILTER_SOURCES.update( {SeeIdeasToExamineView.name: SeeIdeasToExamineView})
CONTENTS_MESSAGES = { '0': _(u"""No followed element was found"""), '1': _(u"""One followed element was found"""), '*': _(u"""${number} followed elements were found""")} @asyn_component_config(id='novaideoapp_seemyselections') @view_config( name='seemyselections', context=NovaIdeoApplication, renderer='pontus:templates/views_templates/grid.pt', ) class SeeMySelectionsView(SeeMyContentsView): title = _('My followings') name = 'seemyselections' behaviors = [SeeMySelections] template = 'novaideo:views/novaideo_view_manager/templates/search_result.pt' viewid = 'seemyselections' contents_messages = CONTENTS_MESSAGES include_archived = False content_types = ['all'] def _get_content_ids(self, user): return [get_oid(o) for o in getattr(user, 'selections', [])] DEFAULTMAPPING_ACTIONS_VIEWS.update({SeeMySelections: SeeMySelectionsView}) FILTER_SOURCES.update( {SeeMySelectionsView.name: SeeMySelectionsView})
self.title = self._get_title( index=index, len_result=len_result, user=user) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs( self.request, batch, user, display_state=getattr(self, 'display_state', True)) if filter_form: result = merge_dicts( {'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) values = {'bodies': result_body, 'batch': batch, 'filter_body': filter_body, 'sort_body': sort_body} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} return result DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeMyContents: SeeMyContentsView}) FILTER_SOURCES.update( {SeeMyContentsView.name: SeeMyContentsView})
index = '*' self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_result}) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs( self.request, batch, user) if filter_form: result = merge_dicts( {'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) values = {'bodies': result_body, 'batch': batch, 'filter_body': filter_body, 'sort_body': sort_body} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} return result DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeOrderedProposal: SeeOrderedProposalView}) FILTER_SOURCES.update( {SeeOrderedProposalView.name: SeeOrderedProposalView})
views = (ProposalsView, ) if 'home-questions' in (delegated_by, view_id): views = (QuestionsView, ) super(HomeView, self)._init_views(views, **kwargs) def update_anonymous(self): values = {} result = {} body = self.content( args=values, template=self.anonymous_template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} self.title = '' self.wrapper_template = 'novaideo:views/novaideo_view_manager/templates/anonymous_view_wrapper.pt' return result def update(self): if not self.request.accessible_to_anonymous: return self.update_anonymous() return super(HomeView, self).update() DEFAULTMAPPING_ACTIONS_VIEWS.update({SeeHome: HomeView}) FILTER_SOURCES.update( {"home": HomeView})
views = (ParticipateView, ChallengeContentsView) @view_config( name='index', context=Challenge, renderer='pontus:templates/views_templates/grid.pt', ) @view_config( name='', context=Challenge, renderer='pontus:templates/views_templates/grid.pt', ) class ChallengeView(MultipleView): title = '' name = 'seechallenge' template = 'pontus:templates/views_templates/simple_multipleview.pt' viewid = 'challenge' css_class = 'panel-transparent' views = (DetailChallengeView, ParticipateContentView) validators = [SeeChallenge.get_validator()] requirements = {'css_links': [], 'js_links': ['novaideo:static/js/analytics.js']} DEFAULTMAPPING_ACTIONS_VIEWS.update({SeeChallenge: ChallengeView}) FILTER_SOURCES.update( {"challenge": ChallengeView})
template = 'novaideo:views/novaideo_view_manager/templates/search_result.pt' viewid = 'seemysupports' contents_messages = CONTENTS_MESSAGES selected_filter = [('metadata_filter', ['negation', 'tree', 'states', 'challenges']), ('temporal_filter', ['negation', 'created_date']), 'text_filter', 'other_filter'] include_archived = False content_types = ['idea', 'proposal'] display_state = False def _get_title(self, **args): user = args.get('user') return _(self.contents_messages[args.get('index')], mapping={ 'number': args.get('len_result'), 'tokens': user.get_len_free_tokens() if hasattr( user, 'get_len_free_tokens') else 0 }) def _get_content_ids(self, user): return user.allocated_tokens.keys() if hasattr( user, 'allocated_tokens') else [] DEFAULTMAPPING_ACTIONS_VIEWS.update({SeeMySupports: SeeMySupportsView}) FILTER_SOURCES.update({SeeMySupportsView.name: SeeMySupportsView})
@view_config( name='seemyparticipations', context=NovaIdeoApplication, renderer='pontus:templates/views_templates/grid.pt', ) class SeeMyParticipationsView(SeeMyContentsView): title = _('My working groups') name = 'seemyparticipations' behaviors = [SeeMyParticipations] template = 'novaideo:views/novaideo_view_manager/templates/search_result.pt' viewid = 'seemyparticipations' contents_messages = CONTENTS_MESSAGES selected_filter = [('metadata_filter', ['keywords', 'states', 'challenges']), ('temporal_filter', ['negation', 'created_date']), 'text_filter', 'other_filter'] include_archived = False content_types = ['proposal'] sorts = ['release_date', 'created_at'] def _get_content_ids(self, user): participations = user.get_participations(user) \ if hasattr(user, 'get_participations') else [] return [get_oid(o) for o in participations] DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeMyParticipations: SeeMyParticipationsView}) FILTER_SOURCES.update({SeeMyParticipationsView.name: SeeMyParticipationsView})
len_result = batch.seqlen index = str(len_result) if len_result > 1: index = '*' self.title = self._get_title(index=index, len_result=len_result, user=user) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs(self.request, batch, user) values = { 'bodies': result_body, 'batch': batch, 'filter_body': filter_body } body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} result['css_links'] = filter_form['css_links'] result['js_links'] = filter_form['js_links'] return result DEFAULTMAPPING_ACTIONS_VIEWS.update({SeeUsers: SeeUsersView}) FILTER_SOURCES.update({ SeeUsersView.name: SeeUsersView, SeeInactiveUsersView.name: SeeInactiveUsersView })
index = '*' self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_result}) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs( self.request, batch, user) if filter_form: result = merge_dicts( {'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) values = {'bodies': result_body, 'batch': batch, 'filter_body': filter_body, 'sort_body': sort_body} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} return result DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeIdeasToModerate: SeeIdeasToModerateView}) FILTER_SOURCES.update( {SeeIdeasToModerateView.name: SeeIdeasToModerateView})
self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_result}) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs(self.request, batch, user) if filter_form: result = merge_dicts( { 'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) values = { 'bodies': result_body, 'batch': batch, 'filter_body': filter_body, 'sort_body': sort_body } body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} return result DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeProposalsToModerate: SeeProposalsToModerateView}) FILTER_SOURCES.update( {SeeProposalsToModerateView.name: SeeProposalsToModerateView})
} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) item['messages'] = messages item['isactive'] = vote_actions['isactive'] or navbars['isactive'] result.update(resources) result['coordinates'] = {self.coordinates: [item]} return result @view_config( name='seequestion', context=Question, renderer='pontus:templates/views_templates/grid.pt', ) class SeeQuestionView(MultipleView): name = 'seequestion' template = 'novaideo:views/templates/entity_multipleview.pt' title = '' views = (SeeQuestionHeaderView, AnswersDetailsView) validators = [SeeQuestion.get_validator()] requirements = { 'css_links': [], 'js_links': ['novaideo:static/js/ballot_management.js'] } DEFAULTMAPPING_ACTIONS_VIEWS.update({SeeQuestion: SeeQuestionView}) FILTER_SOURCES.update({AnswersView.name: AnswersView})
if len_result > 1: index = '*' self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_result}) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs(self.request, batch, user) if filter_form: result = merge_dicts( { 'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) values = { 'bodies': result_body, 'batch': batch, 'filter_body': filter_body, 'sort_body': sort_body } body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} return result DEFAULTMAPPING_ACTIONS_VIEWS.update({SeeIdeasToExamine: SeeIdeasToExamineView}) FILTER_SOURCES.update({SeeIdeasToExamineView.name: SeeIdeasToExamineView})
self.context, self.request.view_name, query=posted) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) batch.target = "#results" len_result = batch.seqlen index = str(len_result) if len_result > 1: index = '*' self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_result}) result_body, result = render_listing_objs( self.request, batch, user) values = {'bodies': result_body, 'batch': batch} # 'sort_body': sort_body} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} return result DEFAULTMAPPING_ACTIONS_VIEWS.update({Search: SearchView}) FILTER_SOURCES.update( {"search_source": SearchResultView})
views = (ProposalsView, ) if 'home-questions' in (delegated_by, view_id): views = (QuestionsView, ) super(HomeView, self)._init_views(views, **kwargs) def update_anonymous(self): values = {} result = {} body = self.content( args=values, template=self.anonymous_template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} self.title = '' self.wrapper_template = 'novaideo:views/novaideo_view_manager/templates/anonymous_view_wrapper.pt' return result def update(self): if not self.request.accessible_to_anonymous: return self.update_anonymous() return super(HomeView, self).update() DEFAULTMAPPING_ACTIONS_VIEWS.update({SeeHome: HomeView}) FILTER_SOURCES.update( {"home": HomeView})
batch.target = "#results_users" len_result = batch.seqlen index = str(len_result) if len_result > 1: index = '*' self.title = self._get_title( index=index, len_result=len_result, user=user) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs( self.request, batch, user) values = {'bodies': result_body, 'batch': batch, 'filter_body': filter_body} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} result['css_links'] = filter_form['css_links'] result['js_links'] = filter_form['js_links'] return result DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeUsers: SeeUsersView}) FILTER_SOURCES.update( {SeeUsersView.name: SeeUsersView, SeeInactiveUsersView.name: SeeInactiveUsersView})
index = '*' self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_result}) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs( self.request, batch, user) if filter_form: result = merge_dicts( {'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) values = {'bodies': result_body, 'batch': batch, 'filter_body': filter_body, 'sort_body': sort_body} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} return result DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeOrderedProposal: SeeOrderedProposalView}) FILTER_SOURCES.update( {SeeOrderedProposalView.name: SeeOrderedProposalView})
user = get_current(self.request) dace_catalog = find_catalog('dace') novaideo_catalog = find_catalog('novaideo') object_authors_index = novaideo_catalog['object_authors'] container_index = dace_catalog['container_oid'] query = container_index.eq(get_oid(self.context)) objects = find_entities( interfaces=[IAmendment], user=user, add_query=query) query = query & object_authors_index.any([get_oid(user)]) my_objs = find_entities( interfaces=[IAmendment], user=user, add_query=query) len_result = len(objects) len_my = len(my_objs) len_others = len_result - len_my bindings['user'] = user bindings['len_result'] = len_result bindings['len_my'] = len_my bindings['len_others'] = len_others setattr(self, '_bindings', bindings) DEFAULTMAPPING_ACTIONS_VIEWS.update({SeeAmendments: AllAmendmentsView}) FILTER_SOURCES.update( {"seeproposalamendments": SeeAmendmentsView})
body = self.content(args=values, template=template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} if filter_form: result['css_links'] = filter_form['css_links'] result['js_links'] = filter_form['js_links'] return result def before_update(self): super(OpenFolderView, self).before_update() folderid = self.params('folderid') try: folder = get_obj(int(folderid)) if folder: self.title = '/'.join([f.title for f in folder.folder_lineage]) except (TypeError, ValueError): self.title = self.request.localizer.translate(_('Folder not valid')) user = get_current() log.info( "Folder not valid. id: ({folderid}) , user: ({user}, {email}) ".format( user=getattr(user, 'title', getattr(user, 'name', 'Anonymous')), email=getattr(user, 'email', 'Anonymous'), folderid=folderid)) DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeSmartFolder: SeeSmartFolderView}) FILTER_SOURCES.update({OpenFolderView.name: OpenFolderView})
self.context, self.request.view_name, query=posted) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) batch.target = "#results" len_result = batch.seqlen index = str(len_result) if len_result > 1: index = '*' self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_result}) result_body, result = render_listing_objs( self.request, batch, user) values = {'bodies': result_body, 'batch': batch} # 'sort_body': sort_body} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} return result DEFAULTMAPPING_ACTIONS_VIEWS.update({Search: SearchView}) FILTER_SOURCES.update( {"search_source": SearchResultView})
self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_result}) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs( self.request, batch, user) if filter_form: result = merge_dicts( {'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) values = {'bodies': result_body, 'batch': batch, 'filter_body': filter_body, 'sort_body': sort_body} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} result = merge_dicts(self.requirements_copy, result) return result DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeReportedContents: SeeReportedContentsView}) FILTER_SOURCES.update( {SeeReportedContentsView.name: SeeReportedContentsView})
batch = Batch( objects, self.request, url=url, default_size=BATCH_HOME_DEFAULT_SIZE) batch.target = "#results-home-challenges" len_result = batch.seqlen user = get_current() if len_result == 0: self.no_challenges = True result = {} result_body = [] else: self.title = self.request.localizer.translate(self.title) result_body, result = render_listing_objs( self.request, batch, user, 'card') values = { 'bodies': result_body, 'batch': batch } body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} return result DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeChallenges: SeeChallengesView}) FILTER_SOURCES.update( {SeeChallengesView.name: SeeChallengesView})
index = '*' self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_result}) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs(self.request, batch, user) if filter_form: result = merge_dicts( { 'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) values = { 'bodies': result_body, 'batch': batch, 'filter_body': filter_body, 'sort_body': sort_body } body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} return result DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeIdeasToModerate: SeeIdeasToModerateView}) FILTER_SOURCES.update({SeeIdeasToModerateView.name: SeeIdeasToModerateView})
index = '*' self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_result}) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs( self.request, batch, user) if filter_form: result = merge_dicts( {'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) values = {'bodies': result_body, 'batch': batch, 'filter_body': filter_body, 'sort_body': sort_body} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} return result DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeProposalsToModerate: SeeProposalsToModerateView}) FILTER_SOURCES.update( {SeeProposalsToModerateView.name: SeeProposalsToModerateView})
self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_result}) filter_data['filter_message'] = self.title filter_body = self.filter_instance.get_body(filter_data) result_body, result = render_listing_objs(self.request, batch, user) if filter_form: result = merge_dicts( { 'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) values = { 'bodies': result_body, 'batch': batch, 'filter_body': filter_body, 'sort_body': sort_body } body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) result['coordinates'] = {self.coordinates: [item]} result = merge_dicts(self.requirements_copy, result) return result DEFAULTMAPPING_ACTIONS_VIEWS.update( {SeeReportedContents: SeeReportedContentsView}) FILTER_SOURCES.update({SeeReportedContentsView.name: SeeReportedContentsView})
CONTENTS_MESSAGES = { '0': _(u"""No followed element was found"""), '1': _(u"""One followed element was found"""), '*': _(u"""${number} followed elements were found""") } @asyn_component_config(id='novaideoapp_seemyselections') @view_config( name='seemyselections', context=NovaIdeoApplication, renderer='pontus:templates/views_templates/grid.pt', ) class SeeMySelectionsView(SeeMyContentsView): title = _('My followings') name = 'seemyselections' behaviors = [SeeMySelections] template = 'novaideo:views/novaideo_view_manager/templates/search_result.pt' viewid = 'seemyselections' contents_messages = CONTENTS_MESSAGES include_archived = False content_types = ['all'] def _get_content_ids(self, user): return [get_oid(o) for o in getattr(user, 'selections', [])] DEFAULTMAPPING_ACTIONS_VIEWS.update({SeeMySelections: SeeMySelectionsView}) FILTER_SOURCES.update({SeeMySelectionsView.name: SeeMySelectionsView})