Example #1
0
    def test_update_detail_not_allowed(self):
        auth = UserObjectsOnlyAuthorization()
        bundle = Mock()
        bundle.request.user = self.user
        bundle.obj = Transaction.objects.filter(user_id=2)[0]

        self.assertFalse(auth.update_detail(Transaction.objects.all(), bundle))
Example #2
0
    def test_create_detail_allowed(self):
        auth = UserObjectsOnlyAuthorization()
        bundle = Mock()
        bundle.request.user = self.user
        bundle.obj = Transaction.objects.filter(user_id=1)[0]

        self.assertTrue(auth.create_detail(Transaction.objects.all(), bundle))
Example #3
0
    def test_update_detail_not_allowed(self):
        auth = UserObjectsOnlyAuthorization()
        bundle = Mock()
        bundle.request.user = self.user
        bundle.obj = Transaction.objects.filter(user_id=2)[0]

        self.assertFalse(auth.update_detail(Transaction.objects.all(), bundle))
Example #4
0
    def test_create_list(self):
        auth = UserObjectsOnlyAuthorization()
        bundle = Mock()

        objs = auth.create_list(Transaction.objects.all(), bundle)

        self.assertEquals(objs.count(), 8)
Example #5
0
    def test_create_detail_allowed(self):
        auth = UserObjectsOnlyAuthorization()
        bundle = Mock()
        bundle.request.user = self.user
        bundle.obj = Transaction.objects.filter(user_id=1)[0]

        self.assertTrue(auth.create_detail(Transaction.objects.all(), bundle))
Example #6
0
    def test_create_list(self):
        auth = UserObjectsOnlyAuthorization()
        bundle = Mock()

        objs = auth.create_list(Transaction.objects.all(), bundle)

        self.assertEquals(objs.count(), 8)
Example #7
0
    def test_update_list(self):
        auth = UserObjectsOnlyAuthorization()
        bundle = Mock()
        bundle.request.user = self.user

        objs = auth.update_list(Transaction.objects.all(), bundle)

        self.assertEquals(len(objs), 4)
Example #8
0
    def test_read_list(self):
        auth = UserObjectsOnlyAuthorization()
        bundle = Mock()
        bundle.request.user = self.user

        objs = auth.read_list(Transaction.objects.all(), bundle)

        self.assertEquals(objs.count(), 4)
Example #9
0
    def test_delete_list(self):
        auth = UserObjectsOnlyAuthorization()
        bundle = Mock()
        bundle.request.user = self.user

        objs = auth.delete_list(Transaction.objects.all(), bundle)

        self.assertEquals(len(objs), 4)
Example #10
0
    def test_read_list(self):
        auth = UserObjectsOnlyAuthorization()
        bundle = Mock()
        bundle.request.user = self.user

        objs = auth.read_list(Transaction.objects.all(), bundle)

        self.assertEquals(objs.count(), 4)
Example #11
0
 class Meta:
     always_return_data = True  # need to set id after POST in Backbone
     queryset = FilterSet.objects.all()
     resource_name = 'filters'  # endpoint is /api/v1/filters/
     authorization = UserObjectsOnlyAuthorization()
     fields = ['id', 'user', 'repo', 'name', 'querystring']
     filtering = {'repo': ('exact'), 'user': ('exact')}
Example #12
0
 class Meta:
     queryset = BaseCategoryRestriction.objects.all()
     always_return_data = True
     authentication = MultiAuthentication(SessionAuthentication(),
                                          BasicAuthentication())
     authorization = UserObjectsOnlyAuthorization()
     validation = FormValidation(form_class=BaseCategoryRestrictionApiForm)
     list_allowed_methods = ['get', 'post']
     detail_allowed_methods = ['get', 'put', 'delete']
     resource_name = "threshold/category"
Example #13
0
 class Meta:
     queryset = Transaction.objects.all()
     always_return_data = True
     excludes = ['created']
     authentication = MultiAuthentication(SessionAuthentication(), BasicAuthentication())
     authorization = UserObjectsOnlyAuthorization()
     validation = FormValidation(form_class=TransactionApiForm)
     list_allowed_methods = ['get', 'post']
     detail_allowed_methods = ['get', 'put', 'delete']
     filtering = {
         'date': ALL
     }
 class Meta:
     resource_name = "split_transaction"
     queryset = SplitTransaction.objects.all()\
         .annotate(total_value=Sum('transactions__value'))\
         .annotate(installments=Count('transactions'))
     always_return_data = True
     authentication = MultiAuthentication(SessionAuthentication(),
                                          BasicAuthentication())
     authorization = UserObjectsOnlyAuthorization()
     validation = CleanedDataFormValidation(
         form_class=SplitTransactionApiForm)
     list_allowed_methods = ['get', 'post']
     detail_allowed_methods = ['get']