def test_cannot_get_it_should_return_405(self):
     url = reverse('update-popit-writeit-relation',
                   subdomain=self.writeitinstance.slug,
                   kwargs={'pk': self.popit_writeit_record.pk})
     request = self.request_factory.get(url)
     request.subdomain = self.writeitinstance.slug
     request.user = self.owner
     request.GET = {'periodicity': 'invalid'}
     response = WriteItPopitUpdateView.as_view()(
         request, pk=self.popit_writeit_record.pk)
     self.assertEquals(response.status_code, 405)
 def test_cannot_get_it_should_return_405(self):
     url = reverse('update-popit-writeit-relation',
             subdomain=self.writeitinstance.slug,
             kwargs={
                 'pk': self.popit_writeit_record.pk
             }
         )
     request = self.request_factory.get(url)
     request.subdomain = self.writeitinstance.slug
     request.user = self.owner
     request.GET = {'periodicity': 'invalid'}
     response = WriteItPopitUpdateView.as_view()(request, pk=self.popit_writeit_record.pk)
     self.assertEquals(response.status_code, 405)
 def test_form_invalid(self):
     url = reverse('update-popit-writeit-relation',
                   subdomain=self.writeitinstance.slug,
                   kwargs={'pk': self.popit_writeit_record.pk})
     request = self.request_factory.post(url)
     request.subdomain = self.writeitinstance.slug
     request.user = self.owner
     request.POST = {'periodicity': 'invalid'}
     response = WriteItPopitUpdateView.as_view()(
         request, pk=self.popit_writeit_record.pk)
     # I'm hoping this to be an ajax call
     self.assertEquals(response.status_code, 200)
     response_object = json.loads(response.content)
     self.assertTrue(response_object['errors'])
 def test_form_invalid(self):
     url = reverse('update-popit-writeit-relation',
             subdomain=self.writeitinstance.slug,
             kwargs={
                 'pk': self.popit_writeit_record.pk
             }
         )
     request = self.request_factory.post(url)
     request.subdomain = self.writeitinstance.slug
     request.user = self.owner
     request.POST = {'periodicity': 'invalid'}
     response = WriteItPopitUpdateView.as_view()(request, pk=self.popit_writeit_record.pk)
     # I'm hoping this to be an ajax call
     self.assertEquals(response.status_code, 200)
     response_object = json.loads(response.content)
     self.assertTrue(response_object['errors'])
 def test_posting_a_new_value_to_the_url_updates_the_value(self):
     url = reverse('update-popit-writeit-relation',
                   subdomain=self.writeitinstance.slug,
                   kwargs={'pk': self.popit_writeit_record.pk})
     request = self.request_factory.post(url)
     request.subdomain = self.writeitinstance.slug
     request.user = self.owner
     request.POST = {'periodicity': '1D'}
     # This is the result of posting
     response = WriteItPopitUpdateView.as_view()(
         request, pk=self.popit_writeit_record.pk)
     # I'm hoping this to be an ajax call
     self.assertEquals(response.status_code, 200)
     response_object = json.loads(response.content)
     self.assertEquals(response_object['id'], self.popit_writeit_record.pk)
     self.assertEquals(response_object['periodicity'], '1D')
     # This is the expected result
     record = WriteitInstancePopitInstanceRecord.objects.get(
         id=self.popit_writeit_record.pk)
     self.assertEquals(record.periodicity, '1D')
 def test_posting_a_new_value_to_the_url_updates_the_value(self):
     url = reverse('update-popit-writeit-relation',
             subdomain=self.writeitinstance.slug,
             kwargs={
                 'pk': self.popit_writeit_record.pk
             }
         )
     request = self.request_factory.post(url)
     request.subdomain = self.writeitinstance.slug
     request.user = self.owner
     request.POST = {'periodicity': '1D'}
     # This is the result of posting
     response = WriteItPopitUpdateView.as_view()(request, pk=self.popit_writeit_record.pk)
     # I'm hoping this to be an ajax call
     self.assertEquals(response.status_code, 200)
     response_object = json.loads(response.content)
     self.assertEquals(response_object['id'], self.popit_writeit_record.pk)
     self.assertEquals(response_object['periodicity'], '1D')
     # This is the expected result
     record = WriteitInstancePopitInstanceRecord.objects.get(id=self.popit_writeit_record.pk)
     self.assertEquals(record.periodicity, '1D')
Example #7
0
managepatterns = patterns('',
    url(r'^$', WriteItInstanceUpdateView.as_view(), name='writeitinstance_basic_update'),
    url(r'^settings/moderation/$', WriteItInstanceModerationView.as_view(), name='writeitinstance_moderation_update'),
    url(r'^moderationqueue/$', ModerationQueue.as_view(), name='writeitinstance_moderation_queue'),
    url(r'^recipients/settings/$', WriteItInstanceRecipientsSettingsView.as_view(), name='writeitinstance_recipients_settings_update'),
    url(r'^settings/ratelimiter/$', WriteItInstanceRateLimiterView.as_view(), name='writeitinstance_ratelimiter_update'),
    url(r'^messages/settings/$', WriteItInstanceAnswerNotificationView.as_view(), name='writeitinstance_answernotification_update'),
    url(r'^api/settings/$', WriteItInstanceApiAutoconfirmView.as_view(), name='writeitinstance_api_autoconfirm_update'),
    url(r'^settings/webbased/$', WriteItInstanceWebBasedView.as_view(), name='writeitinstance_webbased_update'),
    url(r'^settings/api/$', WriteItInstanceApiDocsView.as_view(), name='writeitinstance_api_docs'),
    url(r'^settings/webhooks/$', WriteItInstanceWebHooksView.as_view(), name='writeitinstance_webhooks'),
    url(r'^settings/create_webhooks/$', WriteItInstanceCreateWebHooksView.as_view(), name='writeitinstance_create_webhooks'),
    url(r'^settings/sources/$', WriteitPopitRelatingView.as_view(), name='relate-writeit-popit'),
    url(r'^settings/sources/resync/(?P<popolo_source_pk>[-\d]+)/$', ReSyncFromPopit.as_view(), name='resync-from-popit'),
    url(r'^settings/sources/update/(?P<pk>[-\d]+)/$', WriteItPopitUpdateView.as_view(), name='update-popit-writeit-relation'),
    url(r'^settings/templates/$', WriteItInstanceTemplateUpdateView.as_view(), name='writeitinstance_template_update'),
    url(r'^settings/templates/new_answer_notification/$', NewAnswerNotificationTemplateUpdateView.as_view(), name='edit_new_answer_notification_template'),
    url(r'^settings/templates/confirmation_template/$', ConfirmationTemplateUpdateView.as_view(), name='edit_confirmation_template'),
    url(r'^settings/templates/mailit_template/$', MailitTemplateUpdateView.as_view(), name='mailit-template-update'),
    url(r'^recipients/toggle-enabled/$',
        ToggleContactEnabledView.as_view(),
        name='toggle-enabled'),
    url(r'^recipients/$', WriteItInstanceContactDetailView.as_view(), name='contacts-per-writeitinstance'),
    url(r'^messages/$', MessagesPerWriteItInstance.as_view(), name='messages_per_writeitinstance'),
    url(r'^messages/(?P<pk>[-\d]+)/answers/$', MessageDetail.as_view(), name='message_detail_private'),
    url(r'^messages/(?P<pk>[-\d]+)/answers/create/$', AnswerCreateView.as_view(), name='create_answer'),
    url(r'^messages/(?P<message_pk>[-\d]+)/answers/(?P<pk>[-\d]+)/update/$', AnswerUpdateView.as_view(), name='update_answer'),
    url(r'^messages/(?P<pk>[-\d]+)/accept/$', AcceptMessageView.as_view(), name='accept_message'),
    url(r'^messages/(?P<pk>[-\d]+)/reject/$', RejectMessageView.as_view(), name='reject_message'),
    url(r'^stats/$', StatsView.as_view(), name='stats'),
Example #8
0
     WriteItInstanceApiDocsView.as_view(),
     name='writeitinstance_api_docs'),
 url(r'^settings/webhooks/$',
     WriteItInstanceWebHooksView.as_view(),
     name='writeitinstance_webhooks'),
 url(r'^settings/create_webhooks/$',
     WriteItInstanceCreateWebHooksView.as_view(),
     name='writeitinstance_create_webhooks'),
 url(r'^settings/sources/$',
     WriteitPopitRelatingView.as_view(),
     name='relate-writeit-popit'),
 url(r'^settings/sources/resync/(?P<popolo_source_pk>[-\d]+)/$',
     ReSyncFromPopit.as_view(),
     name='resync-from-popit'),
 url(r'^settings/sources/update/(?P<pk>[-\d]+)/$',
     WriteItPopitUpdateView.as_view(),
     name='update-popit-writeit-relation'),
 url(r'^settings/templates/$',
     WriteItInstanceTemplateUpdateView.as_view(),
     name='writeitinstance_template_update'),
 url(r'^settings/templates/new_answer_notification/$',
     NewAnswerNotificationTemplateUpdateView.as_view(),
     name='edit_new_answer_notification_template'),
 url(r'^settings/templates/confirmation_template/$',
     ConfirmationTemplateUpdateView.as_view(),
     name='edit_confirmation_template'),
 url(r'^settings/templates/mailit_template/$',
     MailitTemplateUpdateView.as_view(),
     name='mailit-template-update'),
 url(r'^recipients/toggle-enabled/$',
     ToggleContactEnabledView.as_view(),
Example #9
0
managepatterns = patterns('',
    url(r'^$', WriteItInstanceUpdateView.as_view(), name='writeitinstance_basic_update'),
    url(r'^settings/moderation/$', WriteItInstanceModerationView.as_view(), name='writeitinstance_moderation_update'),
    url(r'^moderationqueue/$', ModerationQueue.as_view(), name='writeitinstance_moderation_queue'),
    url(r'^recipients/settings/$', WriteItInstanceRecipientsSettingsView.as_view(), name='writeitinstance_recipients_settings_update'),
    url(r'^settings/ratelimiter/$', WriteItInstanceRateLimiterView.as_view(), name='writeitinstance_ratelimiter_update'),
    url(r'^messages/settings/$', WriteItInstanceAnswerNotificationView.as_view(), name='writeitinstance_answernotification_update'),
    url(r'^api/settings/$', WriteItInstanceApiAutoconfirmView.as_view(), name='writeitinstance_api_autoconfirm_update'),
    url(r'^settings/webbased/$', WriteItInstanceWebBasedView.as_view(), name='writeitinstance_webbased_update'),
    url(r'^settings/api/$', WriteItInstanceApiDocsView.as_view(), name='writeitinstance_api_docs'),
    url(r'^settings/webhooks/$', WriteItInstanceWebHooksView.as_view(), name='writeitinstance_webhooks'),
    url(r'^settings/create_webhooks/$', WriteItInstanceCreateWebHooksView.as_view(), name='writeitinstance_create_webhooks'),
    url(r'^settings/sources/$', WriteitPopitRelatingView.as_view(), name='relate-writeit-popit'),
    url(r'^settings/sources/resync/(?P<popolo_source_pk>[-\d]+)/$', ReSyncFromPopit.as_view(), name='resync-from-popit'),
    url(r'^settings/sources/update/(?P<pk>[-\d]+)/$', WriteItPopitUpdateView.as_view(), name='update-popit-writeit-relation'),
    url(r'^settings/templates/$', WriteItInstanceTemplateUpdateView.as_view(), name='writeitinstance_template_update'),
    url(r'^settings/templates/new_answer_notification/$', NewAnswerNotificationTemplateUpdateView.as_view(), name='edit_new_answer_notification_template'),
    url(r'^settings/templates/confirmation_template/$', ConfirmationTemplateUpdateView.as_view(), name='edit_confirmation_template'),
    url(r'^settings/templates/mailit_template/$', MailitTemplateUpdateView.as_view(), name='mailit-template-update'),
    url(r'^recipients/toggle-enabled/$',
        ToggleContactEnabledView.as_view(),
        name='toggle-enabled'),
    url(r'^recipients/$', WriteItInstanceContactDetailView.as_view(), name='contacts-per-writeitinstance'),
    url(r'^messages/$', MessagesPerWriteItInstance.as_view(), name='messages_per_writeitinstance'),
    url(r'^messages/(?P<pk>[-\d]+)/answers/$', MessageDetail.as_view(), name='message_detail_private'),
    url(r'^messages/(?P<pk>[-\d]+)/answers/create/$', AnswerCreateView.as_view(), name='create_answer'),
    url(r'^messages/(?P<message_pk>[-\d]+)/answers/(?P<pk>[-\d]+)/update/$', AnswerUpdateView.as_view(), name='update_answer'),
    url(r'^messages/(?P<pk>[-\d]+)/accept/$', AcceptMessageView.as_view(), name='accept_message'),
    url(r'^messages/(?P<pk>[-\d]+)/reject/$', RejectMessageView.as_view(), name='reject_message'),
    url(r'^stats/$', StatsView.as_view(), name='stats'),