Ejemplo n.º 1
0
    def test_doesnt_add_another_relation_w_p(self):
        '''
        If a user posts to the server using another popolo source that has not previously been related
        it does not add another relation
        '''
        another_popolo_source = PopoloSource.objects.last()
        self.assertNotIn(another_popolo_source,
            self.writeitinstance.writeitinstancepopitinstancerecord_set.all())

        url = reverse('resync-from-popit', subdomain=self.writeitinstance.slug, kwargs={
            'popolo_source_pk': another_popolo_source.pk})
        request = self.request_factory.post(url)
        request.subdomain = self.writeitinstance.slug
        request.user = self.owner
        with self.assertRaises(Http404):
            ReSyncFromPopit.as_view()(request, popolo_source_pk=another_popolo_source.pk)
Ejemplo n.º 2
0
    def test_post_has_to_be_the_owner_of_the_instance(self):
        '''Only the owner of an instance can resync'''
        url = reverse('resync-from-popit', subdomain=self.writeitinstance.slug, kwargs={
            'popolo_source_pk': self.popolo_source.pk})
        request = self.request_factory.post(url)
        request.subdomain = self.writeitinstance.slug
        request.user = AnonymousUser()
        with self.assertRaises(Http404):
            ReSyncFromPopit.as_view()(request, popolo_source_pk=self.popolo_source.pk)

        other_user = User.objects.create_user(username="******", password="******")

        request = self.request_factory.post(url)
        request.subdomain = self.writeitinstance.slug
        request.user = other_user
        with self.assertRaises(Http404):
            ReSyncFromPopit.as_view()(request, popolo_source_pk=self.popolo_source.pk)
Ejemplo n.º 3
0
    def test_post_to_the_url_for_manual_resync(self):
        '''Resyncing can be done by posting to a url'''
        # This is just a symbolism but it is to show how this popit api is empty
        self.assertFalse(PopoloPerson.objects.origin(self.popolo_source))
        url = reverse('resync-from-popit', subdomain=self.writeitinstance.slug, kwargs={
            'popolo_source_pk': self.popolo_source.pk})
        request = self.request_factory.post(url)
        request.subdomain = self.writeitinstance.slug
        request.user = self.owner
        response = ReSyncFromPopit.as_view()(request, popolo_source_pk=self.popolo_source.pk)

        self.assertEquals(response.status_code, 200)
        # It should have been updated
        self.assertTrue(PopoloPerson.objects.origin(self.popolo_source))
Ejemplo n.º 4
0
download_attachment_view = ObjectDownloadView.as_view(model=AnswerAttachment, file_field="content")

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'),
Ejemplo n.º 5
0
     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(),
Ejemplo n.º 6
0
download_attachment_view = ObjectDownloadView.as_view(model=AnswerAttachment, file_field="content")

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'),