Esempio n. 1
0
    def test_project_update_removed_self(self):
        request = RequestFactory().post(
                '/projects/list/{}/edit'.format(self.proj.pk),
                data={
                    'title': 'Test Project Updated',
                    'description': 'A test project',
                    'pi_emails': '[email protected],[email protected],[email protected]',
                    'managers': ['testcuuser','testrequester'],
                    'collaborators': ['testuser','testcuuser'],
                }
            )
        request.user = self.user
        view = ProjectEditView.as_view()
        response = view(request)

        self.assertIs(response.__class__, HttpResponseRedirect)
        self.assertTrue(response.url.startswith('/projects/list/{}/'.format(self.proj.pk)))

        proj = Project.objects.get(project_id='ucb1')
        self.assertEquals(proj.title,'Test Project Updated')
        self.assertEquals(proj.description,'A test project')
        self.assertEquals(proj.pi_emails,['*****@*****.**','*****@*****.**','*****@*****.**'])
        self.assertEquals(proj.managers,['testcuuser','testrequester','testuser'])
        self.assertEquals(proj.collaborators,['testuser','testcuuser'])
        self.assertEquals(proj.organization,'ucb')
Esempio n. 2
0
    def test_project_update_missing_fields(self):
        request = RequestFactory().post(
                '/projects/list/{}/edit'.format(self.proj.pk),
                data={
                    'managers': ['testcuuser','testrequester'],
                    'collaborators': ['testuser','testcuuser'],
                }
            )
        request.user = self.user
        view = ProjectEditView.as_view()
        response = view(request)

        self.assertEquals(
                response.context_data['form'].errors['title'],
                [u'This field is required.']
            )
        self.assertEquals(
                response.context_data['form'].errors['description'],
                [u'This field is required.']
            )
        self.assertEquals(
                response.context_data['form'].errors['pi_emails'],
                [u'This field is required.']
            )
Esempio n. 3
0
File: urls.py Progetto: USEPA/TRACI
# We disable the invalid name because urlpatterns is the Django default
"""
URLs related to managing projects

Available functions:
- None yet
"""

from django.conf.urls import url
from projects.views import ProjectListView, ProjectCreateView, get_projects, \
    ProjectEditView, ProjectDetailView, ProjectDeleteView, \
    ProjectCalculationsView

urlpatterns = [
    url(r'^projects/?$', ProjectListView.as_view(), name='projects'),
    url(r'^create/?$', ProjectCreateView.as_view(), name='create_project'),
    url(r'^edit/(?P<pk>\d+)/?$',
        ProjectEditView.as_view(),
        name='edit_project'),
    url(r'^detail/(?P<pk>\d+)/?$',
        ProjectDetailView.as_view(),
        name='detail_project'),
    url(r'^delete/(?P<pk>\d+)/?$',
        ProjectDeleteView.as_view(),
        name='delete_project'),
    url(r'^calculations/(?P<pk>\d+)/?$',
        ProjectCalculationsView.as_view(),
        name='delete_project'),
    url(r'^get_projects/?$', get_projects, name='get_projects'),
]
Esempio n. 4
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'),
]