Exemplo n.º 1
0
    def test_create_json(self):
        self.insert_test_data()
        self.assertEqual(Commercial.objects.all().count(), 4)
        data = {'brand': 1, 'name': u'test'}

        view = CommercialCreateDataJson.as_view()
        request = self.request_factory.post(
            reverse('panel_model_save_profile'),
            data=dumps(data),
            content_type='application/json')
        request.user = self.user
        response = view(request)
        self.assertEqual(response.status_code, 200)
        content = json.loads(response._container[0])
        self.assertEqual(content.get('status'), "success")
        self.assertEqual(Commercial.objects.all().count(), 5)
Exemplo n.º 2
0
    def test_create_json(self):
        self.insert_test_data()
        self.assertEqual(Commercial.objects.all().count(), 4)
        data = {
            'brand': 1,
            'name': u'test'
        }

        view = CommercialCreateDataJson.as_view()
        request = self.request_factory.post(
            reverse('panel_model_save_profile'), data=dumps(data), content_type='application/json'
        )
        request.user = self.user
        response = view(request)
        self.assertEqual(response.status_code, 200)
        content = json.loads(response._container[0])
        self.assertEqual(content.get('status'), "success")
        self.assertEqual(Commercial.objects.all().count(), 5)
Exemplo n.º 3
0
from django.conf.urls import url, patterns
from apps.sp.views.panel.Commercial import CommercialListView, CommercialCreateView,\
    CommercialUpdateView, CommercialDeleteView, CommercialByBrandIdJson,\
    CommercialDataListView, CommercialCreateDataJson

urlpatterns = patterns(
    '',

    #Commercial
    url(r'^list/$', CommercialListView.as_view(), name='commercial_list'),
    url(r'^create/$', CommercialCreateView.as_view(),
        name='commercial_create'),
    url(r'^edit/(?P<pk>\d+)/$',
        CommercialUpdateView.as_view(),
        name='commercial_edit'),
    url(r'^delete/(?P<pk>\d+)/$',
        CommercialDeleteView.as_view(),
        name='commercial_delete'),
    url(r'^commercial-by-brand/(?P<brand>\d+)/$',
        CommercialByBrandIdJson.as_view(),
        name='commercial_by_brand_json'),
    url(r'^data-list/$',
        CommercialDataListView.as_view(),
        name='commercial_data_list'),
    url(r'^json-create/$',
        CommercialCreateDataJson.as_view(),
        name='commercial_json_create'),
)
Exemplo n.º 4
0
from django.conf.urls import url, patterns
from apps.sp.views.panel.Commercial import CommercialListView, CommercialCreateView,\
    CommercialUpdateView, CommercialDeleteView, CommercialByBrandIdJson,\
    CommercialDataListView, CommercialCreateDataJson

urlpatterns = patterns('',

     #Commercial
    url(r'^list/$',
        CommercialListView.as_view(),
        name='commercial_list'),
    url(r'^create/$',
        CommercialCreateView.as_view(),
        name='commercial_create'),
    url(r'^edit/(?P<pk>\d+)/$',
        CommercialUpdateView.as_view(),
        name='commercial_edit'),
    url(r'^delete/(?P<pk>\d+)/$',
        CommercialDeleteView.as_view(),
        name='commercial_delete'),
    url(r'^commercial-by-brand/(?P<brand>\d+)/$',
        CommercialByBrandIdJson.as_view(),
        name='commercial_by_brand_json'),
    url(r'^data-list/$',
        CommercialDataListView.as_view(),
        name='commercial_data_list'),
    url(r'^json-create/$',
        CommercialCreateDataJson.as_view(),
        name='commercial_json_create'),
)