diff --git a/staff/urls.py b/staff/urls.py index 09128d35b..ad4c67c2d 100644 --- a/staff/urls.py +++ b/staff/urls.py @@ -32,7 +32,6 @@ OrgDetail, OrgEdit, OrgList, - OrgProjectCreate, OrgRemoveGitHubOrg, OrgRemoveMember, org_add_github_org, @@ -135,7 +134,6 @@ path("add/", OrgCreate.as_view(), name="org-create"), path("/", OrgDetail.as_view(), name="org-detail"), path("/add-github-org/", org_add_github_org, name="org-add-github-org"), - path("/add-project/", OrgProjectCreate.as_view(), name="org-project-create"), path("/edit/", OrgEdit.as_view(), name="org-edit"), path( "/remove-member/", OrgRemoveMember.as_view(), name="org-membership-remove" diff --git a/staff/views/orgs.py b/staff/views/orgs.py index fdeb7bcff..7ff2617a2 100644 --- a/staff/views/orgs.py +++ b/staff/views/orgs.py @@ -11,7 +11,7 @@ from jobserver.authorization import CoreDeveloper from jobserver.authorization.decorators import require_permission, require_role -from jobserver.models import Org, OrgMembership, Project, User +from jobserver.models import Org, OrgMembership, User from ..forms import OrgAddGitHubOrgForm, OrgAddMemberForm from ..htmx_tools import get_redirect_url @@ -180,32 +180,6 @@ def get_queryset(self): return qs -@method_decorator(require_role(CoreDeveloper), name="dispatch") -class OrgProjectCreate(CreateView): - fields = ["name"] - model = Project - template_name = "staff/org_project_create.html" - - def dispatch(self, request, *args, **kwargs): - self.org = get_object_or_404(Org, slug=self.kwargs["slug"]) - - return super().dispatch(request, *args, **kwargs) - - def form_valid(self, form): - project = form.save(commit=False) - project.created_by = self.request.user - project.updated_by = self.request.user - project.org = self.org - project.save() - - return redirect(project.get_staff_url()) - - def get_context_data(self, **kwargs): - return super().get_context_data() | { - "org": self.org, - } - - @method_decorator(require_role(CoreDeveloper), name="dispatch") class OrgRemoveGitHubOrg(View): def post(self, request, *args, **kwargs): diff --git a/templates/staff/org_detail.html b/templates/staff/org_detail.html index 864159fbf..cfacae0c3 100644 --- a/templates/staff/org_detail.html +++ b/templates/staff/org_detail.html @@ -48,9 +48,6 @@

{{ org.name }}

diff --git a/templates/staff/org_project_create.html b/templates/staff/org_project_create.html deleted file mode 100644 index 99602f33e..000000000 --- a/templates/staff/org_project_create.html +++ /dev/null @@ -1,65 +0,0 @@ -{% extends "staff/base.html" %} - -{% block metatitle %}{{ org.name }}: Staff Area | OpenSAFELY Jobs{% endblock metatitle %} - -{% block breadcrumbs %} - -{% endblock breadcrumbs %} - -{% block jumbotron %} -
-
-

Create a project

-
-
-{% endblock jumbotron %} - -{% block content %} -
-
-
-
- {% csrf_token %} -
- - Project details - - - {% if form.non_field_errors %} -
    - {% for error in form.non_field_errors %} -
  • {{ error }}
  • - {% endfor %} -
- {% endif %} - - {% include "components/form_text.html" with field=form.name label="Project name" name="name" %} - -
- - - -
-
-
-
-{% endblock content %} diff --git a/tests/unit/staff/views/test_orgs.py b/tests/unit/staff/views/test_orgs.py index 93dc7e561..08f94802f 100644 --- a/tests/unit/staff/views/test_orgs.py +++ b/tests/unit/staff/views/test_orgs.py @@ -1,5 +1,4 @@ import pytest -from django.contrib.auth.models import AnonymousUser from django.contrib.messages.storage.fallback import FallbackStorage from django.core.exceptions import PermissionDenied from django.http import Http404 @@ -11,7 +10,6 @@ OrgDetail, OrgEdit, OrgList, - OrgProjectCreate, OrgRemoveGitHubOrg, OrgRemoveMember, org_add_github_org, @@ -314,55 +312,6 @@ def test_orglist_unauthorized(rf): OrgList.as_view()(request) -def tests_orgprojectcreate_get_success(rf, core_developer): - org = OrgFactory() - - request = rf.get("/") - request.user = core_developer - - response = OrgProjectCreate.as_view()(request, slug=org.slug) - - assert response.status_code == 200 - assert response.context_data["org"] == org - - -def tests_orgprojectcreate_post_success(rf, core_developer): - org = OrgFactory() - - assert org.projects.count() == 0 - - request = rf.post("/", {"name": "Test Project"}) - request.user = core_developer - - response = OrgProjectCreate.as_view()(request, slug=org.slug) - - assert response.status_code == 302 - - project = org.projects.first() - assert project is not None - assert response.url == project.get_staff_url() - assert project.created_by == core_developer - assert project.org == org - - -def tests_orgprojectcreate_unauthorized(rf, core_developer): - org = OrgFactory() - - request = rf.get("/") - request.user = AnonymousUser() - - with pytest.raises(PermissionDenied): - OrgProjectCreate.as_view()(request, slug=org.slug) - - -def tests_orgprojectcreate_unknown_org(rf, core_developer): - request = rf.get("/") - request.user = core_developer - - with pytest.raises(Http404): - OrgProjectCreate.as_view()(request, slug="") - - def test_orgremovegithuborg_success(rf, core_developer): org = OrgFactory(github_orgs=["one", "two"])