Esempio n. 1
0
    def response_change(self, request, obj):
        opts = obj._meta
        verbose_name = opts.verbose_name
        if obj._deferred:
            opts_ = opts.proxy_for_model._meta
            verbose_name = opts_.verbose_name
        return_url = request.GET.get('rtn_url', None)

        if '_saveandsync' in request.POST:
            sync_obj(obj, self.model)
            self.message_user(request, (_(
                "The %(name)s \"%(obj)s\" was changed successfully, and successfully synced to production."
            ) % {
                'name': force_unicode(verbose_name),
                'obj': force_unicode(obj)
            }))
            return HttpResponseRedirect("../")
        elif '_continue' not in request.POST and '_saveasnew' not in request.POST \
                and "_addanother" not in request.POST and self.has_change_permission(request, None) and return_url:
            msg = _('The %(name)s "%(obj)s" was changed successfully.') % {
                'name': force_unicode(verbose_name),
                'obj': force_unicode(obj)
            }
            self.message_user(request, msg)
            return HttpResponseRedirect(return_url)
        else:
            return super(BaseModelAdmin, self).response_change(request, obj)
Esempio n. 2
0
 def sync_selected_items(self, request, queryset):
     n = queryset.count()
     if n:
         for obj in queryset:
             sync_obj(obj, self.model)
         self.message_user(request, _('Successfully synced %(count)d %(items)s.') % {
             'count': n, 'items': model_ngettext(self.opts, n)
         })
Esempio n. 3
0
 def sync_selected_items(self, request, queryset):
     n = queryset.count()
     if n:
         for obj in queryset:
             sync_obj(obj, self.model)
         self.message_user(
             request,
             _('Successfully synced %(count)d %(items)s.') % {
                 'count': n,
                 'items': model_ngettext(self.opts, n)
             })
Esempio n. 4
0
 def response_add(self, request, obj, post_url_continue='../%s/'):
     if "_saveandsync" in request.POST:
         sync_obj(obj, self.model)
         self.message_user(
             request,
             (_("The %(name)s \"%(obj)s\" was added successfully, and successfully synced to production.") %
                 {'name': force_unicode(obj._meta.verbose_name), 'obj': force_unicode(obj)})
         )
         return HttpResponseRedirect("../")
     else:
         return super(BaseModelAdmin, self).response_add(request, obj)
Esempio n. 5
0
 def response_add(self, request, obj, post_url_continue='../%s/'):
     if "_saveandsync" in request.POST:
         sync_obj(obj, self.model)
         self.message_user(request, (_(
             "The %(name)s \"%(obj)s\" was added successfully, and successfully synced to production."
         ) % {
             'name':
             force_unicode(obj._meta.verbose_name),
             'obj':
             force_unicode(obj)
         }))
         return HttpResponseRedirect("../")
     else:
         return super(BaseModelAdmin, self).response_add(request, obj)
Esempio n. 6
0
    def response_change(self, request, obj):
        opts = obj._meta
        verbose_name = opts.verbose_name
        if obj._deferred:
            opts_ = opts.proxy_for_model._meta
            verbose_name = opts_.verbose_name
        return_url = request.GET.get('rtn_url', None)

        if '_saveandsync' in request.POST:
            sync_obj(obj, self.model)
            self.message_user(
                request,
                (_("The %(name)s \"%(obj)s\" was changed successfully, and successfully synced to production.") %
                    {'name': force_unicode(verbose_name), 'obj': force_unicode(obj)})
            )
            return HttpResponseRedirect("../")
        elif '_continue' not in request.POST and '_saveasnew' not in request.POST \
                and "_addanother" not in request.POST and self.has_change_permission(request, None) and return_url:
            msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': force_unicode(verbose_name), 'obj': force_unicode(obj)}
            self.message_user(request, msg)
            return HttpResponseRedirect(return_url)
        else:
            return super(BaseModelAdmin, self).response_change(request, obj)