Пример #1
0
    def test_get_initial_anonymous(self):
        view = ContactUsView()
        view.request = RequestFactory().get('/contact/')
        view.request.session = {}
        view.request.user = AnonymousUser()
        initial = view.get_initial()

        self.assertIsNotNone(initial['issue_date'])
        self.assertFalse('name' in initial)
        self.assertFalse('email' in initial)
        self.assertFalse('username' in initial)
Пример #2
0
    def test_get_initial_not_anonymous(self):
        view = ContactUsView()
        view.request = RequestFactory().get('/contact/')
        view.request.session = {}
        view.request.user = UserFactory(first_name='Foo',
                                        last_name='Bar',
                                        email='*****@*****.**')

        initial = view.get_initial()
        self.assertIsNotNone(initial['issue_date'])
        self.assertEquals(initial['name'], 'Foo Bar')
        self.assertEquals(initial['email'], '*****@*****.**')
        self.assertEquals(initial['username'], view.request.user.username)

        # a subsequent call using an anonymous session returns a clean initial
        view.request.session = {}
        view.request.user = AnonymousUser()
        initial = view.get_initial()
        self.assertIsNotNone(initial['issue_date'])
        self.assertFalse('name' in initial)
        self.assertFalse('email' in initial)
        self.assertFalse('username' in initial)
Пример #3
0
    def test_form_valid_with_support_destination(self):
        view = ContactUsView()
        form = ContactUsForm()
        form.cleaned_data = {
            'issuer_date': datetime.now(),
            'name': 'Linus Torvalds',
            'username': '******',
            'email': '*****@*****.**',
            'course': 'Introduction to Linux',
            'category': 'View Image',
            'description': 'This is a problem'
        }

        with self.settings(SUPPORT_DESTINATION='*****@*****.**',
                           TASK_ASSIGNMENT_DESTINATION=None):
            view.form_valid(form)
            self.assertEqual(len(mail.outbox), 1)

            self.assertEqual(mail.outbox[0].subject,
                             'Mediathread Contact Us Request')
            self.assertEquals(mail.outbox[0].from_email,
                              '*****@*****.**')
            self.assertEquals(mail.outbox[0].to,
                              [settings.SUPPORT_DESTINATION])
Пример #4
0
    path('sequence/', include('mediathread.sequence.urls')),
    auth_urls,  # see above

    # Bookmarklet + cache defeating
    path('bookmarklets/<path:path>analyze.js',
         django.views.static.serve, {'document_root': bookmarklet_root},
         name='analyze-bookmarklet'),
    path('nocache/\w+/bookmarklets/<path:path>',
         django.views.static.serve, {'document_root': bookmarklet_root},
         name='nocache-analyze-bookmarklet'),
    path('comments/', include('django_comments.urls')),

    # Contact us forms.
    path('contact/success/',
         TemplateView.as_view(template_name='main/contact_success.html')),
    path('contact/', ContactUsView.as_view(), name='contact-us'),
    path(
        'course/request/success/',
        TemplateView.as_view(
            template_name='main/course_request_success.html')),
    path('affil/<int:pk>/activate/',
         AffilActivateView.as_view(),
         name='affil_activate'),

    # New course-aware routes
    path('course/<int:course_pk>/react/asset/<int:pk>/',
         ReactAssetDetailView.as_view(),
         name='react_asset_detail'),
    path(
        'course/<int:course_pk>/react/asset/<int:pk>/'
        'annotations/<int:annotation_pk>/',
Пример #5
0
    auth_urls,  # see above

    # Bookmarklet + cache defeating
    url(r'^bookmarklets/(?P<path>analyze.js)$', django.views.static.serve,
        {'document_root': bookmarklet_root}, name='analyze-bookmarklet'),
    url(r'^nocache/\w+/bookmarklets/(?P<path>analyze.js)$',
        django.views.static.serve, {'document_root': bookmarklet_root},
        name='nocache-analyze-bookmarklet'),

    url(r'^comments/', include('django_comments.urls')),

    # Contact us forms.
    url(r'^contact/success/$',
        TemplateView.as_view(template_name='main/contact_success.html')),
    url(r'^contact/$', ContactUsView.as_view()),
    url(r'^course/request/success/$', TemplateView.as_view(
        template_name='main/course_request_success.html')),
    url(r'^affil/(?P<pk>\d+)/activate/$',
        AffilActivateView.as_view(),
        name='affil_activate'),

    url(r'^course/(?P<pk>\d+)/$', CourseDetailView.as_view(),
        name='course_detail'),

    url(r'^course/list/$',
        MethCourseListView.as_view(),
        name='course_list'),
    url(r'^course/lti/create/$',
        LTICourseCreate.as_view(), name='lti-course-create'),
    url(r'^course/lti/(?P<context>\w[^/]*)/$',
Пример #6
0
    url(r'^sequence/', include('mediathread.sequence.urls')),
    auth_urls,  # see above

    # Bookmarklet + cache defeating
    url(r'^bookmarklets/(?P<path>analyze.js)$',
        django.views.static.serve, {'document_root': bookmarklet_root},
        name='analyze-bookmarklet'),
    url(r'^nocache/\w+/bookmarklets/(?P<path>analyze.js)$',
        django.views.static.serve, {'document_root': bookmarklet_root},
        name='nocache-analyze-bookmarklet'),
    url(r'^comments/', include('django_comments.urls')),

    # Contact us forms.
    url(r'^contact/success/$',
        TemplateView.as_view(template_name='main/contact_success.html')),
    url(r'^contact/$', ContactUsView.as_view()),
    url(r'^course/request/success/$',
        TemplateView.as_view(
            template_name='main/course_request_success.html')),
    url(r'^affil/(?P<pk>\d+)/activate/$',
        AffilActivateView.as_view(),
        name='affil_activate'),

    # New course-aware routes
    url(r'^course/(?P<pk>\d+)/$',
        CourseDetailView.as_view(),
        name='course_detail'),
    url(r'^course/(?P<course_pk>\d+)/asset/',
        include('mediathread.assetmgr.urls')),
    url(r'^course/list/$', MethCourseListView.as_view(), name='course_list'),
    url(r'^course/lti/create/$',