def site_settings(request): """ main entrance page (following index ;))""" site = Siteattr.get_site() user = request.user base_usercontainer_id = None # if not user.is_anonymous(): # base_usercontainer_id = UserContainer.objects.filter(creator=user, parent=None) [0].id ctx = { 'user' : request.user.username, 'user_id' : request.user.pk, 'base_usercontainer_id': base_usercontainer_id, 'url_prefix' : settings.URL_PREFIX, 'type' : 'site', 'id' : site.pk, 'site_id' : site.pk, 'site_name' : unicode(site), 'isdebug' : settings.DEBUG, 'isdbghost' : request.get_host(), } #WAS 'isdbghost' : string.find(request.get_host(), ":"), return render_to_xml_response("settings.xml", ctx)
def get_response(self, request, resource_type, resource_id, args): super(BlockWithList, self).get_response(request, resource_type, resource_id, args) if args == "": context = { 'block_type' : self.name, 'resource' : self.resource, 'resource_list' : self._get_resource_list(request), 'user_actions' : self._get_user_actions(request), 'more_info' : self._get_more_context_info(request), } # Not used now if request.GET.get('render_as') == 'resource_list_with_details': template = self.TEMPLATE_RESOURCE_LIST_WITH_DETAILS else: template = self.TEMPLATE_RESOURCE_LIST return render_to_xml_response(template, context) elif args == CREATE: with transaction.commit_on_success(): rv = self._add_resource(request) return rv else: raise NotImplementedError
def site_settings(request): """ main entrance page (following index ;))""" site = Siteattr.get_site() user = request.user base_usercontainer_id = None # if not user.is_anonymous(): # base_usercontainer_id = UserContainer.objects.filter(creator=user, parent=None) [0].id ctx = { 'user': request.user.username, 'user_id': request.user.pk, 'base_usercontainer_id': base_usercontainer_id, 'url_prefix': settings.URL_PREFIX, 'type': 'site', 'id': site.pk, 'site_id': site.pk, 'site_name': unicode(site), 'isdebug': settings.DEBUG, 'isdbghost': request.get_host(), } #WAS 'isdbghost' : string.find(request.get_host(), ":"), return render_to_xml_response("settings.xml", ctx)
def get_response(self, request, resource_type, resource_id, args): super(BlockWithList, self).get_response(request, resource_type, resource_id, args) if args == "": context = { 'block_type': self.name, 'resource': self.resource, 'resource_list': self._get_resource_list(request), 'user_actions': self._get_user_actions(request), 'more_info': self._get_more_context_info(request), } # Not used now if request.GET.get('render_as') == 'resource_list_with_details': template = self.TEMPLATE_RESOURCE_LIST_WITH_DETAILS else: template = self.TEMPLATE_RESOURCE_LIST return render_to_xml_response(template, context) elif args == CREATE: with transaction.commit_on_success(): rv = self._add_resource(request) return rv else: raise NotImplementedError
def get_response(self, request, resource_type, resource_id, args): super(Block, self).get_response(request, resource_type, resource_id, args) res = self.resource user_actions = self._get_user_actions(request) if args == "INCOME": if request.method == 'POST': form = BalanceForm(request, request.POST) if form.is_valid(): with transaction.commit_on_success(): if form.cleaned_data: form.save() # return self.response_success() # else: # return self.response_error(form.errors) else: form = BalanceForm(request) # if args == "": ctx = { 'resource' : res, 'sanet_urn' : "%s/%s" % (resource_type, resource_id), 'form' : BalanceForm(request), 'user_actions' : user_actions, } return render_to_xml_response('blocks/balance.xml', ctx)
def list_notifications(request): context = { #Matteo: to restore when django_notification will be updated 'notifications': [] #Notice.objects.notices_for(request.user, on_site=True) } return render_to_xml_response("notifications_result.xml", context)
def get_response(self, request, resource_type, resource_id, args): super(BlockWithList, self).get_response(request, resource_type, resource_id, args) if args == "": context = { 'block_type': self.name, 'resource': self.resource, 'user_actions': self._get_user_actions(request), } template_name = self.BLOCK_TEMPLATE return render_to_xml_response(template_name, context) elif args == self.KW_DATA: querySet = self._get_resource_list(request) #columnIndexNameMap is required for correct sorting behavior columnIndexNameMap = self.COLUMN_INDEX_NAME_MAP #path to template used to generate json (optional) jsonTemplatePath = 'blocks/%s/data.json' % self.BLOCK_NAME querySet, dt_params = prepare_datatables_queryset( request, querySet, columnIndexNameMap) return render_datatables(request, querySet, dt_params, jsonTemplatePath) elif args == EDIT_MULTIPLE: if request.method == 'POST': return self._do_post_edit_multiple() querySet = self._get_resource_list(request) #columnIndexNameMap is required for correct sorting behavior columnIndexNameMap = self.COLUMN_INDEX_NAME_MAP #path to template used to generate json (optional) jsonTemplatePath = 'blocks/%s/edit_multiple.json' % self.BLOCK_NAME querySet, dt_params = prepare_datatables_queryset( request, querySet, columnIndexNameMap) formset, records, moreData = self._get_records(request, querySet) return render_datatables(request, records, dt_params, jsonTemplatePath, moreData=moreData) elif args == CREATE: with transaction.commit_on_success(): rv = self._add_resource(request) return rv else: raise NotImplementedError("args = %s" % args)
def get_response(self, request, resource_type, resource_id, args): """Check for confidential access permission and call superclass if needed""" if not request.user.has_perm(CASH, obj=ObjectWithContext(request.resource.gas)): return render_to_xml_response("blocks/table_html_message.xml", {"msg": CONFIDENTIAL_VERBOSE_HTML}) return super(Block, self).get_response(request, resource_type, resource_id, args)
def suppliers(request): """ GDXP API suppliers?<key>=<value>*&opt_<option>=<0|1>* Options are: - catalog - order - download """ # If querystring is empty return all suppliers and catalogs supplier_qs = Supplier.objects.all() options = { 'opt_catalog': True, 'opt_order': False, 'opt_download': False, } qs_filter = request.GET.copy() for k, values in qs_filter.iterlists(): for v in values: if k.startswith('opt_'): options.update({k: bool(int(v))}) else: if k.endswith('__in'): v = v.split(',') try: supplier_qs = supplier_qs.filter(**{k: v}) except FieldError as e: return HttpResponse( '<h1>Request parameter is not supported</h1>', status=400, content_type='text/xml') if not supplier_qs: return HttpResponse( '<h1>No supplier found for the requested filter</h1>', status=404, content_type='text/xml') gdxp_version = 'v0_2' xml_response = render_to_xml_response('gdxp/%s/base.xml' % gdxp_version, { 'qs': supplier_qs, 'opts': options }) fname = u"GF_%s.gdxp" % urllib.quote_plus(u"_".join( map(unicode, supplier_qs)).encode('latin-1')) xml_response['Content-Disposition'] = "attachment; filename=%s" % fname return xml_response
def list(request, resource_type): user = request.user ids = [] context = { 'resource_type':resource_type, 'ids':ids } return render_to_xml_response("resource_list.xml", context)
def get_response(self, request, resource_type, resource_id, args): """Check for confidential access permission and call superclass if needed""" if not request.user.has_perm( CASH, obj=ObjectWithContext(request.resource.gas)): return render_to_xml_response("blocks/table_html_message.xml", {'msg': CONFIDENTIAL_VERBOSE_HTML}) return super(Block, self).get_response(request, resource_type, resource_id, args)
def get_response(self, request, resource_type, resource_id, args): """Check for confidential access permission and call superclass if needed""" if not self._check_permission(request): return render_to_xml_response("blocks/table_html_message.xml", {"msg": CONFIDENTIAL_VERBOSE_HTML}) if args == CREATE_CSV: return self._create_csv(request) return super(Block, self).get_response(request, resource_type, resource_id, args)
def suppliers(request): """ GDXP API suppliers?<key>=<value>*&opt_<option>=<0|1>* Options are: - catalog - order - download """ # If querystring is empty return all suppliers and catalogs supplier_qs = Supplier.objects.all() options = { 'opt_catalog' : True, 'opt_order' : False, 'opt_download' : False, } qs_filter = request.GET.copy() for k,values in qs_filter.iterlists(): for v in values: if k.startswith('opt_'): options.update({k : bool(int(v))}) else: if k.endswith('__in'): v = v.split(',') try: supplier_qs = supplier_qs.filter(**{k : v}) except FieldError as e: return HttpResponse('<h1>Request parameter is not supported</h1>', status=400, content_type='text/xml') if not supplier_qs: return HttpResponse('<h1>No supplier found for the requested filter</h1>', status=404, content_type='text/xml') gdxp_version = 'v0_2' xml_response = render_to_xml_response( 'gdxp/%s/base.xml' % gdxp_version, {'qs' : supplier_qs, 'opts' : options} ) fname = u"GF_%s.gdxp" % urllib.quote_plus( u"_".join(map(unicode, supplier_qs)).encode('utf-8') ) xml_response['Content-Disposition'] = "attachment; filename=%s" % fname return xml_response
def options_response(self, request, resource_type, resource_id): """Get options for orders block. Check GAS configuration. WARNING: call to this method doesn't pass through get_response so you have to reset self.request and self.resource attribute if you want """ log.debug("order options_response") self.request = request self.resource = request.resource gas = self.resource.gas orders = gas.orders.open() field_type = "checkbox" if gas.config.order_show_only_next_delivery: orders = orders.order_by('-delivery__date') if orders[0].delivery: orders.filter(delivery__date=orders[0].delivery.date) else: orders.filter(delivery__date__isnull=True) if gas.config.order_show_only_one_at_a_time: field_type = "radio" fields = [] for i, open_order in enumerate(orders): if field_type == "radio": selected = i == 0 else: selected = True fields.append({ 'field_type': field_type, 'field_label': open_order, 'field_name': 'order', 'field_values': [{ 'value': open_order.pk, 'selected': selected }] }) ctx = { 'block_name': self.description, 'fields': fields, } return render_to_xml_response('options.xml', ctx)
def get_response(self, request, resource_type, resource_id, args): """Check for confidential access permission and call superclass if needed""" if not self._check_permission(request): return render_to_xml_response("blocks/table_html_message.xml", {'msg': CONFIDENTIAL_VERBOSE_HTML}) if args == CREATE_CSV: return self._create_csv(request) return super(Block, self).get_response(request, resource_type, resource_id, args)
def get_response(self, request, resource_type, resource_id, args): super(BlockWithList, self).get_response(request, resource_type, resource_id, args) if args == "": context = { 'block_type' : self.name, 'resource' : self.resource, 'user_actions' : self._get_user_actions(request), } template_name = self.BLOCK_TEMPLATE return render_to_xml_response(template_name, context) elif args == self.KW_DATA: querySet = self._get_resource_list(request) #columnIndexNameMap is required for correct sorting behavior columnIndexNameMap = self.COLUMN_INDEX_NAME_MAP #path to template used to generate json (optional) jsonTemplatePath = 'blocks/%s/data.json' % self.BLOCK_NAME querySet, dt_params = prepare_datatables_queryset(request, querySet, columnIndexNameMap) return render_datatables(request, querySet, dt_params, jsonTemplatePath) elif args == EDIT_MULTIPLE: if request.method == 'POST': return self._do_post_edit_multiple() querySet = self._get_resource_list(request) #columnIndexNameMap is required for correct sorting behavior columnIndexNameMap = self.COLUMN_INDEX_NAME_MAP #path to template used to generate json (optional) jsonTemplatePath = 'blocks/%s/edit_multiple.json' % self.BLOCK_NAME querySet, dt_params = prepare_datatables_queryset(request, querySet, columnIndexNameMap) formset, records, moreData = self._get_records(request, querySet) return render_datatables(request, records, dt_params, jsonTemplatePath, moreData=moreData) elif args == CREATE: with transaction.commit_on_success(): rv = self._add_resource(request) return rv else: raise NotImplementedError("args = %s" % args)
def get_response(self, request, resource_type, resource_id, args): """Check for confidential access permission and call superclass if needed""" if resource_type == "gasmember": if not request.user.has_perm( VIEW_CONFIDENTIAL, obj=ObjectWithContext(request.resource) ) and not request.user.has_perm( CASH, obj=ObjectWithContext(request.resource.gas) ): return render_to_xml_response( "blocks/table_html_message.xml", { 'msg' : CONFIDENTIAL_VERBOSE_HTML } ) elif resource_type == "site": if not request.user in request.resource.gas_tech_referrers | \ request.resource.gas_cash_referrers: return render_to_xml_response( "blocks/table_html_message.xml", { 'msg' : CONFIDENTIAL_VERBOSE_HTML } ) else: if not request.user.has_perm( CASH, obj=ObjectWithContext(request.resource.gas) ): return render_to_xml_response( "blocks/table_html_message.xml", { 'msg' : CONFIDENTIAL_VERBOSE_HTML } ) return super(Block, self).get_response(request, resource_type, resource_id, args)
def list_comments(request): resources = [] for prr in request.user.principal_param_role_set.all(): resources += [ r.value.as_dict() for r in prr.role.params ] #TODO: REENABLE ? #rnotes = get_notes_for(resources) rnotes = get_all_notes() context = { 'notes': rnotes } return render_to_xml_response("comments_result.xml", context)
def options_response(self, request, resource_type, resource_id): """Get options for orders block. Check GAS configuration. WARNING: call to this method doesn't pass through get_response so you have to reset self.request and self.resource attribute if you want """ log.debug("order options_response") self.request = request self.resource = request.resource gas = self.resource.gas orders = gas.orders.open() field_type = "checkbox" if gas.config.order_show_only_next_delivery: orders = orders.order_by('-delivery__date') if orders[0].delivery: orders.filter(delivery__date=orders[0].delivery.date) else: orders.filter(delivery__date__isnull=True) if gas.config.order_show_only_one_at_a_time: field_type = "radio" fields = [] for i,open_order in enumerate(orders): if field_type == "radio": selected = i == 0 else: selected = True fields.append({ 'field_type' : field_type, 'field_label' : open_order, 'field_name' : 'order', 'field_values' : [{ 'value' : open_order.pk, 'selected' : selected}] }) ctx = { 'block_name' : self.description, 'fields': fields, } return render_to_xml_response('options.xml', ctx)
def list_comments(request): resources = [] for prr in request.user.principal_param_role_set.all(): for param_role in prr.role.params: resource = param_role.value resources.append(resource) if resource.resource_type == "gas": resources += resource.orders.open() resources += resource.orders.closed() resources += resource.pacts rnotes = get_notes_for(resources) #KO: show all notes to all users #KO: rnotes = get_all_notes() context = {'notes': rnotes} return render_to_xml_response("comments_result.xml", context)
def list_comments(request): resources = [] for prr in request.user.principal_param_role_set.all(): for param_role in prr.role.params: resource = param_role.value resources.append(resource) if resource.resource_type == "gas": resources += resource.orders.open() resources += resource.orders.closed() resources += resource.pacts rnotes = get_notes_for(resources) #KO: show all notes to all users #KO: rnotes = get_all_notes() context = { 'notes': rnotes } return render_to_xml_response("comments_result.xml", context)
def create_page_settings_from_config(page_config, resource, parent=None): for section in page_config: blocks = [] for block_type in section['blocks']: a = create_block_signature_from_resource(block_type, resource) blocks.append(a) section['blocks_signature'] = blocks pt = ['page_config.xml'] ctx = { 'resource': resource, 'parents': parent, 'sections': page_config, } return render_to_xml_response(pt, ctx)
def render_details_block(self, request, resource_type, resource_id): user = request.user res = request.resource if isinstance(res, Site) and not user.is_superuser: res = res.filter(user) info = '' # # LOAD USER OPTIONS. Remember that values are strings! # options = self.load_user_configuration(user, resource_type, resource_id) if not options: options = DETAILS_DEFAULT_OPTIONS # Retrieve resource's cached informations res.load_checkdata_from_cache() # # Calculate visible informations # df = [] for display_field in res.display_fields: element_value = '' element_type = '' element_warning = '' # 'on' will make the value look red #log.debug("DETTAGLIO PRE: ", type(c)) if isinstance(display_field, types.StringTypes) or isinstance( display_field, types.UnicodeType): element_type = 'str' display_field = res._meta.get_field(display_field) element_value = getattr(res, display_field.name) if element_value != None: if isinstance(display_field, display.ResourceList): element_type = 'resourcelist' elif isinstance(element_value, Resource): element_type = 'resource' elif isinstance(display_field, models.EmailField): element_type = 'email' elif isinstance(display_field, models.FileField): element_type = 'file' try: element_value = element_value.url except ValueError: element_value = '' elif isinstance(element_value, bool): element_type = 'bool' else: element_type = 'str' if display_field.choices: element_value = getattr( res, "get_%s_display" % display_field.name)() else: element_type = 'none' element_value = '' if (display_field.name in self.resource.confidential_fields) and \ not self.request.user.has_perm( VIEW_CONFIDENTIAL, obj=ObjectWithContext(self.request.resource) ): element_value = _("confidential data") info_element = { "name": display_field.name, "text": display_field.verbose_name, "type": element_type, "value": element_value, "warning": element_warning } df.append(info_element) # # Calculate resource notes # notes = self.get_notes(res, request.user) # # Calculate allowed user actions # user_actions = self._get_user_actions(request) # # Prepare data for the templage # ctx = { 'resource': res, 'sanet_urn': "%s/%s" % (resource_type, resource_id), 'rimage': res.icon.url, 'display_fields': df, 'more_details': res.details if hasattr(res, 'details') else None, 'notes': notes, 'user_actions': user_actions, 'config': options, } # # RENDER # return render_to_xml_response('blocks/details.xml', ctx)
super(Block, self).get_response(request, resource_type, resource_id, args) res = self.resource if args == "INCOME": if request.method == 'POST': form = InsoluteOrderForm(request, request.POST) if form.is_valid(): with transaction.commit_on_success(): if form.cleaned_data: try: form.save() # return self.response_success() # return HttpResponse(_("Insolute saved")) except Exception, e: msg = ug("Transaction Insolute ERROR: ") + e.message form._errors["amount"] = form.error_class([msg]) else: form = InsoluteOrderForm(request) ctx = { 'resource' : res, 'sanet_urn' : "%s/%s" % (resource_type, resource_id), 'form' : form, 'user_actions' : self._get_user_actions(request), } return render_to_xml_response('blocks/order_insolute.xml', ctx)
module = m[0] itm = m[1]() if (itm.is_valid(resource_type)): if (itm.visible_in_page()): urls.append({ "address": module, "description": itm.get_description() }) except Exception, e: log.debug(e) continue return render_to_xml_response("resource_urls.xml", { "resource_id": resource_id, "resource_type": resource_type, "urls": urls }) # #------------------------------------------------------------------------------# # # #------------------------------------------------------------------------------# def quick_search(request): site = Siteattr.get_site() #TODO: fero TOCHECK, no filter needed for "VIEW" permission
form = InvoiceOrderForm(request, request.POST) if form.is_valid(): with transaction.commit_on_success(): if form.cleaned_data: try: form.save() # return self.response_success() except Exception, e: if settings.FORM_DEBUG: raise else: msg = _("Error in invoice registration: " ) + e.message form._errors["amount"] = form.error_class( [msg]) else: form = InvoiceOrderForm(request) ctx = { 'resource': res, 'sanet_urn': "%s/%s" % (resource_type, resource_id), 'form': form, 'user_actions': user_actions, } return render_to_xml_response('blocks/order_invoice.xml', ctx)
res = self.resource if args == "INCOME": if request.method == 'POST': form = InsoluteOrderForm(request, request.POST) if form.is_valid(): with transaction.commit_on_success(): if form.cleaned_data: try: form.save() # return self.response_success() # return HttpResponse(_("Insolute saved")) except Exception, e: msg = ug( "Transaction Insolute ERROR: ") + e.message form._errors["amount"] = form.error_class( [msg]) else: form = InsoluteOrderForm(request) ctx = { 'resource': res, 'sanet_urn': "%s/%s" % (resource_type, resource_id), 'form': form, 'user_actions': self._get_user_actions(request), } return render_to_xml_response('blocks/order_insolute.xml', ctx)
if args == "INCOME": if request.method == 'POST': if request.user.has_perm(CASH, obj=ObjectWithContext(gas)): form = TransationPACTForm(request, request.POST) if form.is_valid(): with transaction.commit_on_success(): if form.cleaned_data: try: form.save() except Exception, e: msg = ugettext( "Transaction pact ERROR: ") + e.message form._errors["amount"] = form.error_class( [msg]) else: if request.user.has_perm(CASH, obj=ObjectWithContext(gas)): form = TransationPACTForm(request) else: form = BalanceForm(request) ctx = { 'resource': res, 'sanet_urn': "%s/%s" % (resource_type, resource_id), 'form': form, 'user_actions': self._get_user_actions(request), } return render_to_xml_response('blocks/balance_pact.xml', ctx)
def list(request, resource_type): user = request.user ids = [] context = {'resource_type': resource_type, 'ids': ids} return render_to_xml_response("resource_list.xml", context)
def render_details_block(self, request, resource_type, resource_id): user = request.user res = request.resource if isinstance(res, Site) and not user.is_superuser: res = res.filter(user) info = '' # # LOAD USER OPTIONS. Remember that values are strings! # options = self.load_user_configuration (user, resource_type, resource_id) if not options: options = DETAILS_DEFAULT_OPTIONS # Retrieve resource's cached informations res.load_checkdata_from_cache() # # Calculate visible informations # df = [] for display_field in res.display_fields: element_value = '' element_type = '' element_warning = '' # 'on' will make the value look red #log.debug("DETTAGLIO PRE: ", type(c)) if isinstance(display_field, types.StringTypes) or isinstance(display_field, types.UnicodeType): element_type = 'str' display_field= res._meta.get_field(display_field) element_value = getattr(res, display_field.name) if element_value != None: if isinstance(display_field, display.ResourceList): element_type = 'resourcelist' elif isinstance(element_value, Resource): element_type = 'resource' elif isinstance(display_field, models.EmailField): element_type = 'email' elif isinstance(display_field, models.FileField): element_type = 'file' try: element_value = element_value.url except ValueError: element_value = '' elif isinstance(element_value, bool): element_type = 'bool' else: element_type = 'str' if display_field.choices: element_value = getattr(res, "get_%s_display" % display_field.name)() else: element_type = 'none' element_value = '' if (display_field.name in self.resource.confidential_fields) and \ not self.request.user.has_perm( VIEW_CONFIDENTIAL, obj=ObjectWithContext(self.request.resource) ): element_value = _("confidential data") info_element = { "name" : display_field.name, "text" : display_field.verbose_name, "type" : element_type, "value" : element_value, "warning": element_warning } df.append(info_element) # # Calculate resource notes # notes = self.get_notes(res, request.user) # # Calculate allowed user actions # user_actions = self._get_user_actions(request) # # Prepare data for the templage # ctx = { 'resource' : res, 'sanet_urn' : "%s/%s" % (resource_type, resource_id), 'rimage' : res.icon.url, 'display_fields': df, 'more_details' : res.details if hasattr(res, 'details') else None, 'notes' : notes, 'user_actions' : user_actions, 'config' : options, } # # RENDER # return render_to_xml_response('blocks/details.xml', ctx)
try: module = m[0] itm = m[1]() if (itm.is_valid(resource_type)): if (itm.visible_in_page()): urls.append({ "address": module, "description":itm.get_description() }) except Exception, e: log.debug(e) continue return render_to_xml_response("resource_urls.xml", {"resource_id":resource_id, "resource_type":resource_type, "urls":urls}) # #------------------------------------------------------------------------------# # # #------------------------------------------------------------------------------# def quick_search(request): site = Siteattr.get_site() #TODO: fero TOCHECK, no filter needed for "VIEW" permission #if not request.user.is_superuser: # site = site.filter(request.user) q = request.GET['q'] limits = request.REQUEST.getlist('l') if len(limits) == 0:
if request.method == 'POST': form = InvoiceOrderForm(request, request.POST) if form.is_valid(): with transaction.commit_on_success(): if form.cleaned_data: try: form.save() # return self.response_success() except Exception, e: if settings.FORM_DEBUG: raise else: msg = _("Error in invoice registration: ") + e.message form._errors["amount"] = form.error_class([msg]) else: form = InvoiceOrderForm(request) ctx = { 'resource' : res, 'sanet_urn' : "%s/%s" % (resource_type, resource_id), 'form' : form, 'user_actions' : user_actions, } return render_to_xml_response('blocks/order_invoice.xml', ctx)
with transaction.commit_on_success(): if form.cleaned_data: try: form.save() # return self.response_success() except Exception, e: msg = ugettext("Transaction invoice ERROR: ") + e.message #WAS return self.response_error(form.errors) #WAS form._errors.append(msg) #WAS form.ValidationError(_(msg)) form._errors["amount"] = form.error_class([msg]) #WAS: forms errors not rendered --> DO NOTHING render ctx for showing errors # return self.response_error(form.errors) else: if request.user.has_perm(CASH, obj=ObjectWithContext(gas)): form = TransationGASForm(request) else: form = BalanceGASForm(request) ctx = { 'resource' : res, 'sanet_urn' : "%s/%s" % (resource_type, resource_id), 'form' : form, 'user_actions' : self._get_user_actions(request), } return render_to_xml_response('blocks/balance_gas.xml', ctx)
def list_notifications(request): context = { 'notifications': Notice.objects.notices_for(request.user, on_site=True) } return render_to_xml_response("notifications_result.xml", context)