def upload_view(self, request, extra_context=None): """Displays a form that can upload transactions form a Nordea "NDA" transaction file.""" # The revisionform view will check for change permission (via changeform_view), # but we also need to check for add permissions here. if not self.has_add_permission(request): # pragma: no cover raise PermissionDenied model = self.model opts = model._meta try: each_context = self.admin_site.each_context(request) except TypeError: # Django <= 1.7 pragma: no cover each_context = self.admin_site.each_context() # Get the rest of the context. context = dict( each_context, opts = opts, app_label = opts.app_label, module_name = capfirst(opts.verbose_name), title = _("Upload Nordea transactions"), transactions_handler = get_handler_instance('TRANSACTION_CALLBACKS_HANDLER') ) context.update(extra_context or {}) view = self.view_class.as_view() return view(request, context=context)
def decorator(f): instance = get_handler_instance(setting) if not instance: return f @functools.wraps(f) def wrapper(*args, **kwargs): with transaction.atomic(): instance.on_saving(*args, **kwargs) r = f(*args, **kwargs) instance.on_saved(*args, **kwargs) return r return wrapper
def upload_view(self, request, extra_context=None): """Displays a form that can upload transactions form a Nordea "NDA" transaction file.""" # The revisionform view will check for change permission (via changeform_view), # but we also need to check for add permissions here. if not self.has_add_permission(request): # pragma: no cover raise PermissionDenied model = self.model opts = model._meta try: each_context = self.admin_site.each_context(request) except TypeError: # Django <= 1.7 pragma: no cover each_context = self.admin_site.each_context() # Get the rest of the context. context = dict(each_context, opts=opts, app_label=opts.app_label, module_name=capfirst(opts.verbose_name), title=_("Upload Nordea transactions"), transactions_handler=get_handler_instance( 'TRANSACTION_CALLBACKS_HANDLER')) context.update(extra_context or {}) view = self.view_class.as_view() return view(request, context=context)