Beispiel #1
0
    def test_reference_create_missing_fields(self):
        request = RequestFactory().post(
                '/projects/list/{}/references/create'.format(self.proj.pk),
                data={}
            )
        request.user = self.user
        view = ReferenceCreateView.as_view()
        response = view(request)

        self.assertEquals(
                response.context_data['form'].errors['description'],
                [u'This field is required.']
            )
        self.assertEquals(
                response.context_data['form'].errors['link'],
                [u'This field is required.']
            )
Beispiel #2
0
    def test_reference_create(self):

        request = RequestFactory().post(
                '/projects/{}/references/create'.format(self.proj.pk),
                data={
                    'description': 'A reference.',
                    'link': 'A link',
                }
            )
        request.user = self.user
        view = ReferenceCreateView.as_view()
        response = view(request)

        self.assertTrue(response.url.startswith('/projects/list/{}/references/'.format(self.proj.pk)))

        ref = Reference.objects.get(pk=1)
        self.assertEquals(ref.project.project_id,self.proj.project_id)
        self.assertEquals(ref.description,'A reference.')
        self.assertEquals(ref.link,'A link')
Beispiel #3
0
from django.conf.urls import include, url
from django.contrib.auth.decorators import login_required
from projects.views import ProjectListView
from projects.views import ProjectDetailView
from projects.views import ProjectEditView
from projects.views import ProjectCreateView
from projects.views import ReferenceDetailView
from projects.views import ReferenceEditView
from projects.views import ReferenceCreateView
from projects.views import AllocationRequestDetailView
from projects.views import AllocationRequestCreateView

urlpatterns = [
    url(r'^list$', login_required(ProjectListView.as_view()), name='project-list'),
    url(r'^list/(?P<pk>[-\w]+)/$', login_required(ProjectDetailView.as_view()), name='project-detail'),
    url(r'^list/(?P<pk>[-\w]+)/edit$', login_required(ProjectEditView.as_view()), name='project-edit'),
    url(r'^create$', login_required(ProjectCreateView.as_view()), name='project-create'),
    url(r'^list/(?P<project_pk>[-\w]+)/references/(?P<pk>[-\w]+)/$', login_required(ReferenceDetailView.as_view()), name='reference-detail'),
    url(r'^list/(?P<project_pk>[-\w]+)/references/(?P<pk>[-\w]+)/edit$', login_required(ReferenceEditView.as_view()), name='reference-edit'),
    url(r'^list/(?P<project_pk>[-\w]+)/references/create$', login_required(ReferenceCreateView.as_view()), name='reference-create'),
    url(r'^list/(?P<project_pk>[-\w]+)/allocationrequests/(?P<pk>[-\w]+)/$', login_required(AllocationRequestDetailView.as_view()), name='allocation-request-detail'),
    url(r'^list/(?P<project_pk>[-\w]+)/allocationrequests/create$', login_required(AllocationRequestCreateView.as_view()), name='allocation-request-create'),
]