def update(self): user = get_current() filter_form, filter_data = self._add_filter(user) args = merge_with_filter_view(self, {}) args['request'] = self.request filters = [ { 'metadata_filter': { 'states': ['published'], 'interfaces': [IAnswer] } }, ] # Answer is non a searchable element # we need add it to the args dict args['interfaces'] = [IAnswer] objects = find_entities(filters=filters, user=user, intersect=self._get_answers(user), **args) objects, sort_body = sort_view_objects(self, objects, ['answer'], user, 'nbsupport') url = self.request.resource_url(self.context, self.name) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) batch.target = "#results-answers" len_answers = batch.seqlen index = str(len_answers) if len_answers <= 1 else '*' if not self.parent: self.title = _(CONTENTS_MESSAGES[index], mapping={'number': len_answers}) elif index != '*': self.title = _('The answer') 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, 'empty_message': self.empty_message, 'empty_icon': self.empty_icon, 'filter_body': filter_body, 'sort_body': sort_body, 'view': self } body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) item['isactive'] = True result['coordinates'] = {self.coordinates: [item]} return result
def update(self): body = '' result = {} if self.isactive or self.params('on_demand') == 'load': user = get_current() filter_form, filter_data = self._add_filter(user) default_content = [self.content_type] validated = self._get_validated({ 'metadata_filter': {'content_types': default_content, 'states': ['active', 'published']}, }, user) args = {} args = merge_with_filter_view(self, args) args['request'] = self.request objects = find_entities( user=user, filters=[validated], **args) objects, sort_body = sort_view_objects( self, objects, [self.content_type], user) url = self.request.resource_url( self.context, '', query={'view_content_id': self.content_id}) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) self.title = _(self.title, mapping={'nb': batch.seqlen}) batch.target = "#results-" + self.content_id filter_instance = getattr(self, 'filter_instance', None) filter_body = None if filter_instance: filter_data['filter_message'] = self.title filter_body = filter_instance.get_body(filter_data) result_body, result = render_listing_objs( self.request, batch, user, display_state=getattr(self, 'display_state', True)) values = {'bodies': result_body, 'batch': batch, 'empty_message': self.empty_message, 'empty_icon': self.empty_icon, 'filter_body': filter_body, 'filter_class': self.filter_class, 'sort_body': sort_body, 'view': self} if filter_form: result = merge_dicts( {'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) item['isactive'] = self.isactive result['coordinates'] = {self.coordinates: [item]} return result
def update(self): body = '' result = {} if self.isactive or self.params('on_demand') == 'load': user = get_current() filter_form, filter_data = self._add_filter(user) default_content = [self.content_type] validated = self._get_validated({ 'metadata_filter': {'content_types': default_content, 'states': ['active', 'published']}, }, user) args = {} args = merge_with_filter_view(self, args) args['request'] = self.request objects = find_entities( user=user, filters=[validated], **args) objects, sort_body = sort_view_objects( self, objects, [self.content_type], user) url = self.request.resource_url( self.context, '', query={'view_content_id': self.content_id}) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) self.title = _(self.title, mapping={'nb': batch.seqlen}) batch.target = "#results-" + self.content_id filter_instance = getattr(self, 'filter_instance', None) filter_body = None if filter_instance: filter_data['filter_message'] = self.title filter_body = filter_instance.get_body(filter_data) result_body, result = render_listing_objs( self.request, batch, user, display_state=getattr(self, 'display_state', True)) values = {'bodies': result_body, 'batch': batch, 'empty_message': self.empty_message, 'empty_icon': self.empty_icon, 'filter_body': filter_body, 'filter_class': self.filter_class, 'sort_body': sort_body, 'view': self} if filter_form: result = merge_dicts( {'css_links': filter_form['css_links'], 'js_links': filter_form['js_links'] }, result) body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) item['isactive'] = self.isactive result['coordinates'] = {self.coordinates: [item]} return result
def update(self): self.execute(None) user = get_current() is_manager = has_role(user=user, role=('PortalManager', )) filters = [ {'metadata_filter': { 'content_types': ['person'] }} ] filter_form, filter_data = self._add_filter(user, is_manager) args = merge_with_filter_view(self, {}) args['request'] = self.request objects = find_entities( user=user, filters=filters, **args) objects, sort_body = sort_view_objects( self, objects, ['person'], user) url = self.request.resource_url(self.context, self.name) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) 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) novaideo_catalog = find_catalog('novaideo') last_connection_index = novaideo_catalog['last_connection'] current_date = datetime.datetime.combine( datetime.datetime.now(), datetime.time(0, 0, 0, tzinfo=pytz.UTC)) inactive_users = find_users( last_connection_index, current_date, (INACTIVITY_DURATION, None)) 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, 'is_manager': is_manager, 'inactivity_duration': INACTIVITY_DURATION, 'inactive_users': inactive_users.__len__(), '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
def update(self): self.execute(None) user = get_current() filter_form, filter_data = self._add_filter(user) args = merge_with_filter_view(self, {}) args['request'] = self.request objects = find_entities(user=user, intersect=self._get_content_ids(user), include_archived=self.include_archived, **args) objects, sort_body = sort_view_objects(self, objects, self.content_types, user, intersect=getattr( self, 'sorts', None)) url = self.request.resource_url(self.context, self.name) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) batch.target = "#results_contents" 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, 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
def update(self): body = '' result = {} if self.isactive or self.params('on_demand') == 'load': current_user = get_current() validated = { 'metadata_filter': { 'content_types': [self.content_type], 'states': ['active', 'published'] } } novaideo_catalog = find_catalog('novaideo') organizations_index = novaideo_catalog['organizations'] query = organizations_index.any([self.context.__oid__]) objects = find_entities(user=current_user, filters=[validated], add_query=query) sort_url = self.request.resource_url( self.context, '@@index', query={'view_content_attr': self.content_id}) objects, sort_body = sort_view_objects(self, objects, [self.content_type], current_user, sort_url=sort_url) url = self.request.resource_url( self.context, '@@index', query={'view_content_attr': self.content_id}) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) batch.target = "#results-" + self.content_type self.title = _(self.title, mapping={'nb': batch.seqlen}) result_body, result = render_listing_objs( self.request, batch, current_user, display_state=getattr(self, 'display_state', True)) values = { 'bodies': result_body, 'batch': batch, 'empty_message': self.empty_message, 'empty_icon': self.empty_icon, 'sort_body': sort_body } body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) item['isactive'] = getattr(self, 'isactive', False) result['coordinates'] = {self.coordinates: [item]} return result
def update(self): self.execute(None) user = get_current() filter_form, filter_data = self._add_filter(user) filters = [{ 'metadata_filter': { 'negation': True, 'states': ['examined'] } }, { 'metadata_filter': { 'content_types': ['idea'], 'states': ['published'] } }] args = {} args = merge_with_filter_view(self, args) args['request'] = self.request objects = find_entities(user=user, filters=filters, **args) objects, sort_body = sort_view_objects(self, objects, ['idea'], user, 'nbsupport') url = self.request.resource_url(self.context, 'seeideastoexamine') batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) batch.target = "#results_contents" len_result = batch.seqlen index = str(len_result) 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
def update(self): body = '' result = {} if self.isactive or self.params('on_demand') == 'load': user = self.context current_user = get_current() objects = [] if current_user is user: objects = list( filter(lambda o: 'archived' not in o.state, getattr(user, self.content_attr, []))) else: objects = list( filter( lambda o: can_access(current_user, o) and 'archived' not in o.state, getattr(user, self.content_attr, []))) sort_url = self.request.resource_url( self.context, '@@index', query={'view_content_id': self.content_id}) objects, sort_body = sort_view_objects(self, objects, [self.content_type], user, sort_url=sort_url) url = self.request.resource_url( self.context, '@@index', query={'view_content_id': self.content_id}) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) batch.target = "#results-" + self.content_id self.title = _(self.title, mapping={'nb': batch.seqlen}) result_body, result = render_listing_objs( self.request, batch, current_user, display_state=getattr(self, 'display_state', True)) values = { 'bodies': result_body, 'batch': batch, 'empty_message': self.empty_message, 'empty_icon': self.empty_icon, 'sort_body': sort_body } body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) item['isactive'] = getattr(self, 'isactive', False) result['coordinates'] = {self.coordinates: [item]} return result
def update(self): self.execute(None) user = get_current() filter_form, filter_data = self._add_filter(user) filters = [ {'metadata_filter': { 'negation': True, 'states': ['examined'] }}, {'metadata_filter': { 'content_types': ['idea'], 'states': ['published'] }} ] args = {} args = merge_with_filter_view(self, args) args['request'] = self.request objects = find_entities(user=user, filters=filters, **args) objects, sort_body = sort_view_objects( self, objects, ['idea'], user, 'nbsupport') url = self.request.resource_url(self.context, 'seeideastoexamine') batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) batch.target = "#results_contents" len_result = batch.seqlen index = str(len_result) 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
def update(self): self.execute(None) user = get_current() is_manager = has_role(user=user, role=('PortalManager', )) filters = [{'metadata_filter': {'content_types': ['person']}}] filter_form, filter_data = self._add_filter(user, is_manager) args = merge_with_filter_view(self, {}) args['request'] = self.request objects = find_entities(user=user, filters=filters, **args) objects, sort_body = sort_view_objects(self, objects, ['person'], user) url = self.request.resource_url(self.context, self.name) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) 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) novaideo_catalog = find_catalog('novaideo') last_connection_index = novaideo_catalog['last_connection'] current_date = datetime.datetime.combine( datetime.datetime.now(), datetime.time(0, 0, 0, tzinfo=pytz.UTC)) inactive_users = find_users(last_connection_index, current_date, (INACTIVITY_DURATION, None)) 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, 'is_manager': is_manager, 'inactivity_duration': INACTIVITY_DURATION, 'inactive_users': inactive_users.__len__(), '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
def update(self): body = '' result = {} if self.isactive or self.params('on_demand') == 'load': current_user = get_current() validated = { 'metadata_filter': {'content_types': [self.content_type], 'states': ['active', 'published']} } novaideo_catalog = find_catalog('novaideo') organizations_index = novaideo_catalog['organizations'] query = organizations_index.any([self.context.__oid__]) objects = find_entities( user=current_user, filters=[validated], add_query=query) sort_url = self.request.resource_url( self.context, '@@index', query={'view_content_attr': self.content_id}) objects, sort_body = sort_view_objects( self, objects, [self.content_type], current_user, sort_url=sort_url) url = self.request.resource_url( self.context, '@@index', query={'view_content_attr': self.content_id}) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) batch.target = "#results-" + self.content_type self.title = _(self.title, mapping={'nb': batch.seqlen}) result_body, result = render_listing_objs( self.request, batch, current_user, display_state=getattr(self, 'display_state', True)) values = {'bodies': result_body, 'batch': batch, 'empty_message': self.empty_message, 'empty_icon': self.empty_icon, 'sort_body': sort_body} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) item['isactive'] = getattr(self, 'isactive', False) result['coordinates'] = {self.coordinates: [item]} return result
def update(self): body = '' result = {} if self.isactive or self.params('on_demand') == 'load': user = self.context current_user = get_current() objects = [] if current_user is user: objects = list(filter(lambda o: 'archived' not in o.state, getattr(user, self.content_attr, []))) else: objects = list(filter(lambda o: can_access(current_user, o) and 'archived' not in o.state, getattr(user, self.content_attr, []))) sort_url = self.request.resource_url( self.context, '@@index', query={'view_content_id': self.content_id}) objects, sort_body = sort_view_objects( self, objects, [self.content_type], user, sort_url=sort_url) url = self.request.resource_url( self.context, '@@index', query={'view_content_id': self.content_id}) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) batch.target = "#results-" + self.content_id self.title = _(self.title, mapping={'nb': batch.seqlen}) result_body, result = render_listing_objs( self.request, batch, current_user, display_state=getattr(self, 'display_state', True)) values = {'bodies': result_body, 'batch': batch, 'empty_message': self.empty_message, 'empty_icon': self.empty_icon, 'sort_body': sort_body} body = self.content(args=values, template=self.template)['body'] item = self.adapt_item(body, self.viewid) item['isactive'] = getattr(self, 'isactive', False) result['coordinates'] = {self.coordinates: [item]} return result
def update(self): result = {} user = get_current() folderid = self.params('folderid') try: folder = get_obj(int(folderid)) except: folder = None # if not valid folderid if folderid is None or folder is None: error = ViewError() error.principalmessage = _("Access to the requested folder has been denied") error.causes = [_("Folder not valid")] message = error.render_message(self.request) item = self.adapt_item('', self.viewid) item['messages'] = {error.type: [message]} result['coordinates'] = {self.coordinates: [item]} return result # if permission denied if folder and not can_access(user, folder): error = ViewError() error.principalmessage = _("Access to the requested folder has been denied") error.causes = [_("Permission denied")] message = error.render_message(self.request) item = self.adapt_item('', self.viewid) item['messages'] = {error.type: [message]} result['coordinates'] = {self.coordinates: [item]} return result # calling self._add_filter will set self.filter_instance or not template_type = getattr(folder, 'view_type', 'default') if template_type == 'bloc': self.wrapper_template = 'novaideo:views/smart_folder_management/templates/folder_blocs_view_wrapper.pt' filter_body = None filter_form, filter_data = self._add_filter(folder, user) args = merge_with_filter_view(self, {}) objects = get_folder_content(folder, user, **args) objects, sort_body = sort_view_objects( self, objects, ['proposal', 'idea', 'amendment', 'file', 'person'], user) len_result = len(objects) self.breadcrumb = self.content( args={'number': len_result}, template=self.breadcrumb_template)['body'] if getattr(self, 'filter_instance', None) is not None: filter_data['filter_message'] = self.breadcrumb filter_body = getattr(self, 'filter_instance').get_body(filter_data) url = self.request.resource_url( self.context, 'open', query={'folderid': folderid}) batch = Batch(objects, self.request, url=url, default_size=BATCH_DEFAULT_SIZE) batch.target = "#results" result_body = [] for obj in batch: body = render_listing_obj( self.request, obj, user, view_type=template_type) if body: result_body.append(body) values = { 'bodies': result_body, 'batch': batch, 'filter_body': filter_body, 'sort_body': sort_body, 'row_len': math.ceil(len_result/2) } template = self.templates.get(template_type, 'default') 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