當前位置: 首頁>>代碼示例>>Python>>正文


Python views.AjaxUpdateAreaView類代碼示例

本文整理匯總了Python中daguerre.views.AjaxUpdateAreaView的典型用法代碼示例。如果您正苦於以下問題:Python AjaxUpdateAreaView類的具體用法?Python AjaxUpdateAreaView怎麽用?Python AjaxUpdateAreaView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AjaxUpdateAreaView類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_post__add

    def test_post__add(self):
        area = self.create_area(x2=50, y2=50)
        self.assertEqual(Area.objects.count(), 1)
        view = AjaxUpdateAreaView()
        view.kwargs = {
            'storage_path': area.storage_path,
            'pk': None,
        }

        params = {
            'x1': 50,
            'y1': 50,
            'x2': 100,
            'y2': 100,
            'priority': 1,
            'name': 'fun'
        }
        request = self.factory.post('/', params,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        request.user = self.create_user(permissions=['daguerre.change_area',
                                                     'daguerre.add_area'])
        self.assertTrue(request.user.has_perm('daguerre.change_area'))
        self.assertTrue(request.user.has_perm('daguerre.add_area'))
        with self.assertNumQueries(3):
            response = view.post(request)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['Content-Type'], "application/json")
        self.assertEqual(Area.objects.count(), 2)
        data = json.loads(force_text(response.content))
        new_area = Area.objects.exclude(pk=area.pk).get()
        self.assertEqual(data, new_area.serialize())
        del data['storage_path']
        del data['id']
        self.assertEqual(data, params)
開發者ID:fabrixxm,項目名稱:django-daguerre,代碼行數:35,代碼來源:test_views.py

示例2: test_post__add__no_perms

    def test_post__add__no_perms(self):
        area = self.create_area(x2=50, y2=50)
        self.assertEqual(Area.objects.count(), 1)
        view = AjaxUpdateAreaView()
        view.kwargs = {
            'storage_path': area.storage_path,
            'pk': None,
        }

        params = {
            'x1': 50,
            'y1': 50,
            'x2': 100,
            'y2': 100,
            'priority': 1,
            'name': 'fun'
        }
        request = self.factory.post('/', params,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        request.user = self.create_user(permissions=['daguerre.change_area'])
        self.assertTrue(request.user.has_perm('daguerre.change_area'))
        with self.assertNumQueries(1):
            response = view.post(request)

        self.assertEqual(response.status_code, 403)
        self.assertEqual(Area.objects.count(), 1)
        self.assertEqual(force_text(response.content), '')
開發者ID:fabrixxm,項目名稱:django-daguerre,代碼行數:27,代碼來源:test_views.py

示例3: test_post__invalid_params

    def test_post__invalid_params(self):
        area = self.create_area(x2=50, y2=50)
        view = AjaxUpdateAreaView()
        view.kwargs = {
            'storage_path': area.storage_path,
            'pk': area.pk,
        }

        params = {
            'x1': 0,
            'y1': 0,
            'x2': 50,
            'y2': 50,
            'priority': 3,
        }
        user = self.create_user(permissions=['daguerre.change_area'])
        self.assertTrue(user.has_perm('daguerre.change_area'))
        for key in params:
            params_copy = params.copy()
            params_copy[key] = 'hi'
            request = self.factory.post('/', params_copy,
                                        HTTP_X_REQUESTED_WITH='XMLHttpRequest')
            request.user = user
            with self.assertNumQueries(0):
                self.assertRaises(Http404, view.post, request)
開發者ID:fabrixxm,項目名稱:django-daguerre,代碼行數:25,代碼來源:test_views.py

示例4: test_get__pk__wrong

 def test_get__pk__wrong(self):
     area = self.create_area(x2=50, y2=50)
     view = AjaxUpdateAreaView()
     view.kwargs = {
         'storage_path': area.storage_path,
         'pk': area.pk + 1,
     }
     request = self.factory.get('/', HTTP_X_REQUESTED_WITH='XMLHttpRequest')
     with self.assertNumQueries(1):
         self.assertRaises(Http404, view.get, request)
開發者ID:fabrixxm,項目名稱:django-daguerre,代碼行數:10,代碼來源:test_views.py

示例5: test_post__no_change_perms

	def test_post__no_change_perms(self):
		view = AjaxUpdateAreaView()
		request = self.factory.post('/', HTTP_X_REQUESTED_WITH='XMLHttpRequest')
		request.user = AnonymousUser()
		self.assertFalse(request.user.has_perm('daguerre.change_area'))
		with self.assertNumQueries(0):
			response = view.post(request)

		self.assertEqual(response.status_code, 403)
		self.assertEqual(response.content, '')
開發者ID:roverdotcom,項目名稱:django-daguerre,代碼行數:10,代碼來源:test_views.py

示例6: test_get__pk

    def test_get__pk(self):
        area = self.create_area(x2=50, y2=50)
        view = AjaxUpdateAreaView()
        view.kwargs = {
            'storage_path': area.storage_path,
            'pk': area.pk,
        }
        request = self.factory.get('/', HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        with self.assertNumQueries(1):
            response = view.get(request)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['Content-Type'], "application/json")
        data = json.loads(force_text(response.content))
        self.assertEqual(data, area.serialize())
開發者ID:fabrixxm,項目名稱:django-daguerre,代碼行數:15,代碼來源:test_views.py

示例7: test_delete__no_pk

	def test_delete__no_pk(self):
		area = self.create_area(x2=50, y2=50)
		self.assertEqual(Area.objects.count(), 1)
		view = AjaxUpdateAreaView()
		view.kwargs = {
			'storage_path': area.storage_path,
			'pk': None,
		}

		request = self.factory.delete('/', HTTP_X_REQUESTED_WITH='XMLHttpRequest')
		request.user = self.create_user(permissions=['daguerre.delete_area'])
		self.assertTrue(request.user.has_perm('daguerre.delete_area'))
		with self.assertNumQueries(0):
			self.assertRaises(Http404, view.delete, request)

		self.assertEqual(Area.objects.count(), 1)
開發者ID:roverdotcom,項目名稱:django-daguerre,代碼行數:16,代碼來源:test_views.py

示例8: test_delete

	def test_delete(self):
		area = self.create_area(x2=50, y2=50)
		self.assertEqual(Area.objects.count(), 1)
		view = AjaxUpdateAreaView()
		view.kwargs = {
			'storage_path': area.storage_path,
			'pk': area.pk,
		}

		request = self.factory.delete('/', HTTP_X_REQUESTED_WITH='XMLHttpRequest')
		request.user = self.create_user(permissions=['daguerre.delete_area'])
		self.assertTrue(request.user.has_perm('daguerre.delete_area'))
		with self.assertNumQueries(3):
			response = view.delete(request)

		self.assertEqual(response.status_code, 200)
		self.assertEqual(response.content, '')
		self.assertEqual(Area.objects.count(), 0)
開發者ID:roverdotcom,項目名稱:django-daguerre,代碼行數:18,代碼來源:test_views.py

示例9: test_delete__no_perms

	def test_delete__no_perms(self):
		area = self.create_area(x2=50, y2=50)
		self.assertEqual(Area.objects.count(), 1)
		view = AjaxUpdateAreaView()
		view.kwargs = {
			'storage_path': area.storage_path,
			'pk': area.pk,
		}

		request = self.factory.delete('/', HTTP_X_REQUESTED_WITH='XMLHttpRequest')
		request.user = AnonymousUser()
		self.assertFalse(request.user.has_perm('daguerre.delete_area'))
		with self.assertNumQueries(0):
			response = view.delete(request)

		self.assertEqual(response.status_code, 403)
		self.assertEqual(Area.objects.count(), 1)
		self.assertEqual(response.content, '')
開發者ID:roverdotcom,項目名稱:django-daguerre,代碼行數:18,代碼來源:test_views.py

示例10: test_post__update

    def test_post__update(self):
        area = self.create_area(x2=50, y2=50)
        self.assertEqual(Area.objects.count(), 1)
        old_serialize = area.serialize()
        view = AjaxUpdateAreaView()
        view.kwargs = {
            'storage_path': area.storage_path,
            'pk': area.pk,
        }

        params = {
            'x1': 50,
            'y1': 50,
            'x2': 100,
            'y2': 100,
            'priority': 1,
            'name': 'fun'
        }
        request = self.factory.post('/', params,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        request.user = self.create_user(permissions=['daguerre.change_area'])
        self.assertTrue(request.user.has_perm('daguerre.change_area'))
        # SB: Used to assert 4 - don't remember why.
        # Three queries expected: get the area, update the area,
        # and clear the adjustment cache.
        with self.assertNumQueries(3):
            response = view.post(request)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response['Content-Type'], "application/json")
        self.assertEqual(Area.objects.count(), 1)
        data = json.loads(force_text(response.content))
        new_area = Area.objects.get(pk=area.pk, storage_path=area.storage_path)
        self.assertEqual(data, new_area.serialize())
        self.assertNotEqual(data, old_serialize)
        del data['storage_path']
        del data['id']
        self.assertEqual(data, params)
開發者ID:fitodic,項目名稱:django-daguerre,代碼行數:38,代碼來源:test_views.py

示例11: import

from django.conf.urls.defaults import patterns, url

from daguerre.views import (AdjustedImageRedirectView, AjaxAdjustmentInfoView,
                            AjaxUpdateAreaView)


urlpatterns = patterns(
    '',
    url(r'^adjust/(?P<storage_path>.+)$',
        AdjustedImageRedirectView.as_view(),
        name="daguerre_adjusted_image_redirect"),
    url(r'^info/(?P<storage_path>.+)$',
        AjaxAdjustmentInfoView.as_view(),
        name="daguerre_ajax_adjustment_info"),
    url(r'^area/(?P<storage_path>.+?)(?:/(?P<pk>\d+))?$',
        AjaxUpdateAreaView.as_view(),
        name="daguerre_ajax_update_area"),
)
開發者ID:philipkimmey,項目名稱:django-daguerre,代碼行數:18,代碼來源:urls.py

示例12: patterns

from django.conf.urls.defaults import patterns, url
from daguerre.views import AdjustedImageRedirectView, AjaxAdjustmentInfoView, AjaxUpdateAreaView

urlpatterns = patterns('',
	url(r'^adjust/(?P<storage_path>.+)$', AdjustedImageRedirectView.as_view(), name="daguerre_adjusted_image_redirect"),
	url(r'^info/(?P<storage_path>.+)$', AjaxAdjustmentInfoView.as_view(), name="daguerre_ajax_adjustment_info"),
	url(r'^area/(?P<storage_path>.+?)(?:/(?P<pk>\d+))?$', AjaxUpdateAreaView.as_view(), name="daguerre_ajax_update_area"),
)
開發者ID:roverdotcom,項目名稱:django-daguerre,代碼行數:8,代碼來源:urls.py


注:本文中的daguerre.views.AjaxUpdateAreaView類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。