Exemple #1
0
 def test_status_other(self):
     for s in amo.STATUS_CHOICES.keys():
         if s in [amo.STATUS_NULL, amo.STATUS_PUBLIC_WAITING]:
             continue
         self.addon.status = s
         status = StatusForm(instance=self.addon).fields['status']
         eq_([k for k, v in status.choices], [k])
Exemple #2
0
    def obj_update(self, bundle, request, **kwargs):
        try:
            obj = self.get_object_list(bundle.request).get(**kwargs)
        except Addon.DoesNotExist:
            raise ImmediateHttpResponse(response=http.HttpNotFound())

        if not AppOwnerAuthorization().is_authorized(request, object=obj):
            raise ImmediateHttpResponse(response=http.HttpForbidden())

        form = StatusForm(bundle.data, instance=obj)
        if not form.is_valid():
            raise self.form_errors(form)

        form.save()
        log.info('App status updated: %s' % obj.pk)
        bundle.obj = obj
        return bundle
Exemple #3
0
    def obj_update(self, bundle, request, **kwargs):
        try:
            obj = self.get_object_list(bundle.request).get(**kwargs)
        except Addon.DoesNotExist:
            raise ImmediateHttpResponse(response=http.HttpNotFound())

        if not AppOwnerAuthorization().is_authorized(request, object=obj):
            raise ImmediateHttpResponse(response=http.HttpForbidden())

        form = StatusForm(bundle.data, instance=obj)
        if not form.is_valid():
            raise self.form_errors(form)

        form.save()
        log.info('App status updated: %s' % obj.pk)
        bundle.obj = obj
        return bundle
Exemple #4
0
    def obj_update(self, bundle, request, **kwargs):
        try:
            obj = self.get_object_list(bundle.request).get(**kwargs)
        except Addon.DoesNotExist:
            raise http_error(http.HttpNotFound, 'No such addon.')

        if not AppOwnerAuthorization().is_authorized(request, object=obj):
            raise http_error(http.HttpForbidden,
                             'You are not an author of that app.')

        form = StatusForm(bundle.data, instance=obj)
        if not form.is_valid():
            raise self.form_errors(form)

        form.save()
        log.info('App status updated: %s' % obj.pk)
        bundle.obj = obj
        return bundle
Exemple #5
0
    def obj_update(self, bundle, request, **kwargs):
        try:
            obj = self.get_object_list(bundle.request).get(**kwargs)
        except Addon.DoesNotExist:
            raise http_error(http.HttpNotFound, 'No such addon.')

        if not AppOwnerAuthorization().is_authorized(request, object=obj):
            raise http_error(http.HttpForbidden,
                             'You are not an author of that app.')

        form = StatusForm(bundle.data, instance=obj)
        if not form.is_valid():
            raise self.form_errors(form)

        form.save()
        log.info('App status updated: %s' % obj.pk)
        bundle.obj = obj
        return bundle
Exemple #6
0
 def test_status_public(self):
     self.addon.status = amo.STATUS_PUBLIC_WAITING
     status = StatusForm(instance=self.addon).fields['status']
     eq_([k for k, v in status.choices], ['public', 'waiting'])
Exemple #7
0
 def test_status_null(self):
     self.addon.status = amo.STATUS_NULL
     status = StatusForm(instance=self.addon).fields['status']
     eq_([k for k, v in status.choices], ['incomplete', 'pending'])