diff --git a/tests/compat/test_redirections.py b/tests/compat/test_redirections.py index 6a25bebb..c8555203 100644 --- a/tests/compat/test_redirections.py +++ b/tests/compat/test_redirections.py @@ -1,7 +1,7 @@ import pytest from django_webtest import DjangoTestApp from django.contrib.redirects.models import Redirect - +from vitrina.users.models import User @pytest.mark.django_db def test_redirection_doesnt_exist(app: DjangoTestApp): @@ -28,3 +28,197 @@ def test_redirection_exists_no_new_path(app: DjangoTestApp): ) response = app.get('/labas/', expect_errors=True) assert response.status_code == 410 + + +@pytest.mark.django_db +def test_dataset_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/dataset/1/', + new_path='/datasets/1/', + ) + response = app.get('/dataset/1/') + assert response.status_code == 301 and response.location == '/datasets/1/' + +@pytest.mark.django_db +def test_usecases_examples_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/usecases/examples/', + new_path='/projects/', + ) + response = app.get('/usecases/examples/') + assert response.status_code == 301 and response.location == '/projects/' + +@pytest.mark.django_db +def test_usecases_applications_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/usecases/applications/', + new_path='/projects/', + ) + response = app.get('/usecases/applications/') + assert response.status_code == 301 and response.location == '/projects/' + +@pytest.mark.django_db +def test_usecase_has_new_path(app: DjangoTestApp): + user1 = User.objects.create_user(email='user1@test.com', password='12345') + app.set_user(user1) + Redirect.objects.create( + site_id=1, + old_path='/usecase/', + new_path='/projects/add/', + ) + response = app.get('/usecase/') + assert response.status_code == 301 and response.location == '/projects/add/' + +@pytest.mark.django_db +def test_policy_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/page/regulation', + new_path='/more/regulation/', + ) + response = app.get('/page/regulation/') + assert response.status_code == 301 and response.location == '/more/regulation/' + + +@pytest.mark.django_db +def test_links_have_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/page/nuorodos', + new_path='/more/nuorodos/', + ) + response = app.get('/page/nuorodos/') + assert response.status_code == 301 and response.location == '/more/nuorodos/' + +@pytest.mark.django_db +def test_notions_have_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/page/savokos', + new_path='/more/savokos/', + ) + response = app.get('/page/savokos/') + assert response.status_code == 301 and response.location == '/more/savokos/' + +@pytest.mark.django_db +def test_about_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/page/apie', + new_path='/more/apie/', + ) + response = app.get('/page/apie/') + assert response.status_code == 301 and response.location == '/more/apie/' + +@pytest.mark.django_db +def test_contacts_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/page/contacts', + new_path='/more/contacts/', + ) + response = app.get('/page/contacts/') + assert response.status_code == 301 and response.location == '/more/contacts/' + +@pytest.mark.django_db +def test_other_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/other', + new_path='/more/other/', + ) + response = app.get('/other/') + assert response.status_code == 301 and response.location == '/more/other/' + +@pytest.mark.django_db +def test_reports_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/reports', + new_path='/more/reports/', + ) + response = app.get('/reports/') + assert response.status_code == 301 and response.location == '/more/reports/' + +@pytest.mark.django_db +def test_templates_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/page/templates', + new_path='/more/templates/', + ) + response = app.get('/page/templates/') + assert response.status_code == 301 and response.location == '/more/templates/' + +@pytest.mark.django_db +def test_storage_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/page/saugykla', + new_path='/opening-tips/saugykla/', + ) + response = app.get('/page/saugykla/') + assert response.status_code == 301 and response.location == '/opening-tips/saugykla/' + +@pytest.mark.django_db +def test_guide_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/page/vadovas', + new_path='/opening-tips/vadovas/', + ) + response = app.get('/page/vadovas/') + assert response.status_code == 301 and response.location == '/opening-tips/vadovas/' + +@pytest.mark.django_db +def test_guide_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/page/vadovas', + new_path='/opening-tips/vadovas/', + ) + response = app.get('/page/vadovas/') + assert response.status_code == 301 and response.location == '/opening-tips/vadovas/' + +@pytest.mark.django_db +def test_summary_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/page/aprasas', + new_path='/opening-tips/aprasas/', + ) + response = app.get('/page/aprasas/') + assert response.status_code == 301 and response.location == '/opening-tips/aprasas/' + +@pytest.mark.django_db +def test_data_opening_tools_have_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/page/data-opening-tools', + new_path='/opening-tips/data-opening-tools/', + ) + response = app.get('/page/data-opening-tools/') + assert response.status_code == 301 and response.location == '/opening-tips/data-opening-tools/' + +@pytest.mark.django_db +def test_learning_material_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/opening/learningmaterial', + new_path='/opening-tips/opening/learningmaterial/', + ) + response = app.get('/opening/learningmaterial/') + assert response.status_code == 301 and response.location == '/opening-tips/opening/learningmaterial/' + +@pytest.mark.django_db +def test_faq_has_new_path(app: DjangoTestApp): + Redirect.objects.create( + site_id=1, + old_path='/page/opening_faq', + new_path='/opening-tips/opening_faq/', + ) + response = app.get('/page/opening_faq/') + assert response.status_code == 301 and response.location == '/opening-tips/opening_faq/' \ No newline at end of file diff --git a/tests/datasets/test_views.py b/tests/datasets/test_views.py index 3ab8fe6a..3b56d069 100644 --- a/tests/datasets/test_views.py +++ b/tests/datasets/test_views.py @@ -554,7 +554,7 @@ def test_public_manager_filtering(app: DjangoTestApp): def test_change_form_no_login(app: DjangoTestApp): org = OrganizationFactory() dataset = DatasetFactory(organization=org) - response = app.get(reverse('dataset-change', kwargs={'pk': dataset.id})) + response = app.get(reverse('dataset-update', kwargs={'pk': dataset.id})) assert response.status_code == 302 assert settings.LOGIN_URL in response.location @@ -565,7 +565,7 @@ def test_change_form_wrong_login(app: DjangoTestApp): dataset = DatasetFactory(organization=org) user = User.objects.create_user(email="test@test.com", password="test123") app.set_user(user) - response = app.get(reverse('dataset-change', kwargs={'pk': dataset.id})) + response = app.get(reverse('dataset-update', kwargs={'pk': dataset.id})) assert response.status_code == 302 assert str(dataset.id) in response.location @@ -588,7 +588,7 @@ def test_change_form_correct_login(app: DjangoTestApp): user = UserFactory(is_staff=True) app.set_user(user) dataset.manager = user - form = app.get(reverse('dataset-change', kwargs={'pk': dataset.id})).forms['dataset-form'] + form = app.get(reverse('dataset-update', kwargs={'pk': dataset.id})).forms['dataset-form'] form['title'] = 'Edited title' form['description'] = 'edited dataset description' resp = form.submit() @@ -607,7 +607,7 @@ def test_group_change_form_correct_login(app: DjangoTestApp): dataset = DatasetFactory() user = UserFactory(is_staff=True) app.set_user(user) - form = app.get(reverse('dataset-change', kwargs={'pk': dataset.id})).forms['dataset-form'] + form = app.get(reverse('dataset-update', kwargs={'pk': dataset.id})).forms['dataset-form'] form['groups'] = ['1'] resp = form.submit() dataset.refresh_from_db() @@ -748,7 +748,7 @@ def test_dataset_history_view_with_permission(app: DjangoTestApp): dataset = DatasetFactory(organization=user.organization) app.set_user(user) - form = app.get(reverse("dataset-change", args=[dataset.pk])).forms['dataset-form'] + form = app.get(reverse("dataset-update", args=[dataset.pk])).forms['dataset-form'] form['title'] = "Updated title" form['description'] = "Updated description" resp = form.submit().follow() diff --git a/tests/resources/test_views.py b/tests/resources/test_views.py index 206ace3b..8db906a1 100644 --- a/tests/resources/test_views.py +++ b/tests/resources/test_views.py @@ -15,7 +15,7 @@ def test_change_form_wrong_login(app: DjangoTestApp): resource = DatasetDistributionFactory() user = User.objects.create_user(email="test@test.com", password="test123") app.set_user(user) - response = app.get(reverse('resource-change', kwargs={'pk': resource.id})) + response = app.get(reverse('resource-update', kwargs={'pk': resource.id})) assert response.status_code == 302 assert str(resource.dataset_id) in response.location @@ -25,7 +25,7 @@ def test_change_form_correct_login(app: DjangoTestApp): resource = DatasetDistributionFactory(title='base title', description='base description') user = UserFactory(is_staff=True, organization=resource.dataset.organization) app.set_user(user) - form = app.get(reverse('resource-change', kwargs={'pk': resource.id})).forms['resource-form'] + form = app.get(reverse('resource-update', kwargs={'pk': resource.id})).forms['resource-form'] form['title'] = "Edited title" form['description'] = "edited resource description" resp = form.submit() @@ -95,7 +95,7 @@ def test_click_add_button(app: DjangoTestApp): @pytest.mark.django_db def test_delete_no_login(app: DjangoTestApp): resource = DatasetDistributionFactory() - response = app.get(reverse('resource-delete', kwargs={'pk': resource.id})) + response = app.get(reverse('resource-remove', kwargs={'pk': resource.id})) assert response.status_code == 302 assert settings.LOGIN_URL in response.location @@ -105,7 +105,7 @@ def test_delete_wrong_login(app: DjangoTestApp): user = UserFactory() app.set_user(user) resource = DatasetDistributionFactory() - response = app.get(reverse('resource-delete', kwargs={'pk': resource.id})) + response = app.get(reverse('resource-remove', kwargs={'pk': resource.id})) assert response.status_code == 302 assert str(resource.dataset_id) in response.location @@ -115,7 +115,7 @@ def test_delete_correct_login(app: DjangoTestApp): resource = DatasetDistributionFactory(title='base title', description='base description') user = UserFactory(is_staff=True, organization=resource.dataset.organization) app.set_user(user) - resp = app.get(reverse('resource-delete', kwargs={'pk': resource.pk})) + resp = app.get(reverse('resource-remove', kwargs={'pk': resource.pk})) assert resp.status_code == 302 assert DatasetDistribution.objects.filter().count() == 0 diff --git a/tests/users/test_views.py b/tests/users/test_views.py index 1f43defb..7edf2410 100644 --- a/tests/users/test_views.py +++ b/tests/users/test_views.py @@ -149,7 +149,7 @@ def test_profile_view_wrong_login(app: DjangoTestApp, user: User): @pytest.mark.django_db def test_profile_edit_form_no_login(app: DjangoTestApp, user: User): - resp = app.get(reverse('user-profile-change', kwargs={'pk': '1'})) + resp = app.get(reverse('user-profile-update', kwargs={'pk': '1'})) assert resp.status_code == 302 assert resp.location == settings.LOGIN_URL @@ -158,7 +158,7 @@ def test_profile_edit_form_no_login(app: DjangoTestApp, user: User): def test_profile_edit_form_wrong_login(app: DjangoTestApp, user: User): app.set_user(user) temp_user = User.objects.create_user(email="testas@testas.com", password="testas123") - resp = app.get(reverse('user-profile-change', kwargs={'pk': temp_user.pk})) + resp = app.get(reverse('user-profile-update', kwargs={'pk': temp_user.pk})) assert resp.status_code == 302 assert str(user.pk) in resp.location @@ -167,7 +167,7 @@ def test_profile_edit_form_wrong_login(app: DjangoTestApp, user: User): def test_profile_edit_form_correct_login(app: DjangoTestApp): user = User.objects.create_user(email="testas@testas.com", password="testas123") app.set_user(user) - form = app.get(reverse('user-profile-change', kwargs={'pk': user.pk})).forms['user-profile-form'] + form = app.get(reverse('user-profile-update', kwargs={'pk': user.pk})).forms['user-profile-form'] form['phone'] = '12341234' resp = form.submit() user.refresh_from_db() diff --git a/vitrina/cms/urls.py b/vitrina/cms/urls.py index fbd75011..96f51db3 100644 --- a/vitrina/cms/urls.py +++ b/vitrina/cms/urls.py @@ -1,5 +1,6 @@ from django.urls import path, include from djangocms_blog.settings import get_setting +from django.http.response import HttpResponsePermanentRedirect from vitrina.cms.views import PolicyView, PostDetailView, LearningMaterialDetailView, SparqlView, ReportDetailView @@ -27,6 +28,20 @@ def get_urls(): path('opening/learningmaterial//', LearningMaterialDetailView.as_view(), name='learning-material-detail'), path('reports//', ReportDetailView.as_view(), name='report-detail'), path('sparql/', SparqlView.as_view(), name='sparql'), + path('page/regulation/', lambda request: HttpResponsePermanentRedirect('/more/regulation/')), + path('page/nuorodos/', lambda request: HttpResponsePermanentRedirect('/more/nuorodos/')), + path('page/savokos/', lambda request: HttpResponsePermanentRedirect('/more/savokos/')), + path('page/apie/', lambda request: HttpResponsePermanentRedirect('/more/apie/')), + path('page/contacts/', lambda request: HttpResponsePermanentRedirect('/more/contacts/')), + path('other/', lambda request: HttpResponsePermanentRedirect('/more/other/')), + path('reports/', lambda request: HttpResponsePermanentRedirect('/more/reports/')), + path('page/templates/', lambda request: HttpResponsePermanentRedirect('/more/templates/')), + path('page/saugykla/', lambda request: HttpResponsePermanentRedirect('/opening-tips/saugykla/')), + path('page/vadovas/', lambda request: HttpResponsePermanentRedirect('/opening-tips/vadovas/')), + path('page/aprasas/', lambda request: HttpResponsePermanentRedirect('/opening-tips/aprasas/')), + path('page/data-opening-tools/', lambda request: HttpResponsePermanentRedirect('/opening-tips/data-opening-tools/')), + path('opening/learningmaterial/', lambda request: HttpResponsePermanentRedirect('/opening-tips/opening/learningmaterial/')), + path('page/opening_faq/', lambda request: HttpResponsePermanentRedirect('/opening-tips/opening_faq/')), # @GetMapping("/other") # @GetMapping("/opening") # @GetMapping("/opening/tips") diff --git a/vitrina/datasets/templates/vitrina/datasets/datatable.html b/vitrina/datasets/templates/vitrina/datasets/datatable.html index afe8e271..23a22c8e 100644 --- a/vitrina/datasets/templates/vitrina/datasets/datatable.html +++ b/vitrina/datasets/templates/vitrina/datasets/datatable.html @@ -66,13 +66,13 @@ {% endif %} {% if can_add_resource %} - {% translate "Redaguoti" %} - {% translate "Trinti" %} diff --git a/vitrina/datasets/templates/vitrina/datasets/detail.html b/vitrina/datasets/templates/vitrina/datasets/detail.html index 3110e9aa..7e3c086e 100644 --- a/vitrina/datasets/templates/vitrina/datasets/detail.html +++ b/vitrina/datasets/templates/vitrina/datasets/detail.html @@ -32,7 +32,7 @@

{% if can_update_dataset %} diff --git a/vitrina/datasets/templates/vitrina/datasets/members_list.html b/vitrina/datasets/templates/vitrina/datasets/members_list.html index 82a0a765..d145b242 100644 --- a/vitrina/datasets/templates/vitrina/datasets/members_list.html +++ b/vitrina/datasets/templates/vitrina/datasets/members_list.html @@ -52,7 +52,7 @@ {% translate "Redaguoti" %} + href="{% url 'dataset-representative-remove' dataset_id=dataset.pk pk=m.pk %}"> {% translate "Pašalinti" %} diff --git a/vitrina/datasets/urls.py b/vitrina/datasets/urls.py index 87eb7a59..77ef50ae 100644 --- a/vitrina/datasets/urls.py +++ b/vitrina/datasets/urls.py @@ -1,5 +1,6 @@ from django.conf.urls import url from django.urls import path +from django.http.response import HttpResponsePermanentRedirect from vitrina.datasets.models import Dataset from vitrina.datasets.views import autocomplete_tags @@ -20,8 +21,9 @@ # @GetMapping("/datasets") path('datasets/', DatasetListView.as_view(), name='dataset-list'), # @GetMapping("/dataset/{slug}") + path('dataset//', lambda request, slug: HttpResponsePermanentRedirect('/datasets/{slug}/'.format(slug=slug))), path('datasets//add/', DatasetCreateView.as_view(), name='dataset-add'), - path('datasets//update/', DatasetUpdateView.as_view(), name='dataset-change'), + path('datasets//update/', DatasetUpdateView.as_view(), name='dataset-update'), path('datasets//', DatasetDetailView.as_view(), name='dataset-detail'), path('datasets//preview//', DatasetDistributionPreviewView.as_view(), name='dataset-distribution-preview'), @@ -43,14 +45,14 @@ name='dataset-representative-create', ), path( - 'datasets//members//change/', + 'datasets//members//update/', UpdateMemberView.as_view(), name='dataset-representative-update', ), path( - 'datasets//members//delete/', + 'datasets//members//remove/', DeleteMemberView.as_view(), - name='dataset-representative-delete', + name='dataset-representative-remove', ), path( 'datasets/tags/autocomplete/', diff --git a/vitrina/orgs/templates/vitrina/orgs/members.html b/vitrina/orgs/templates/vitrina/orgs/members.html index 4135212f..52daadc7 100644 --- a/vitrina/orgs/templates/vitrina/orgs/members.html +++ b/vitrina/orgs/templates/vitrina/orgs/members.html @@ -50,7 +50,7 @@ - + {% translate "Pašalinti" %} diff --git a/vitrina/orgs/urls.py b/vitrina/orgs/urls.py index 46c6b954..6c957591 100644 --- a/vitrina/orgs/urls.py +++ b/vitrina/orgs/urls.py @@ -13,10 +13,10 @@ path('orgs//datasets/', DatasetListView.as_view(), name='organization-datasets'), path('orgs//members/add/', RepresentativeCreateView.as_view(), name='representative-create'), - path('orgs//members//change/', RepresentativeUpdateView.as_view(), + path('orgs//members//update/', RepresentativeUpdateView.as_view(), name='representative-update'), - path('orgs//members//delete/', RepresentativeDeleteView.as_view(), - name='representative-delete'), + path('orgs//members//remove/', RepresentativeDeleteView.as_view(), + name='representative-remove'), path('register//', RepresentativeRegisterView.as_view(), name='representative-register'), # @GetMapping("/partner/register") # @PostMapping("/partner/register") diff --git a/vitrina/projects/urls.py b/vitrina/projects/urls.py index 530ae983..05bec6ab 100644 --- a/vitrina/projects/urls.py +++ b/vitrina/projects/urls.py @@ -1,14 +1,18 @@ from django.urls import path +from django.http.response import HttpResponsePermanentRedirect from vitrina.projects.views import ProjectListView, ProjectDetailView, ProjectCreateView, ProjectUpdateView, \ ProjectHistoryView, ProjectDatasetsView, RemoveDatasetView urlpatterns = [ # @GetMapping("/usecases/examples") + path('usecases/examples/', lambda request: HttpResponsePermanentRedirect('/projects/')), + path('usecases/applications/', lambda request: HttpResponsePermanentRedirect('/projects/')), + path('usecase/', lambda request: HttpResponsePermanentRedirect('/projects/add/')), path('projects/', ProjectListView.as_view(), name='project-list'), path('projects/', ProjectDetailView.as_view(), name='project-detail'), path('projects/add/', ProjectCreateView.as_view(), name='project-create'), - path('projects//change/', ProjectUpdateView.as_view(), name='project-update'), + path('projects//update/', ProjectUpdateView.as_view(), name='project-update'), path('projects//history/', ProjectHistoryView.as_view(), name='project-history'), path('projects//datasets/', ProjectDatasetsView.as_view(), name='project-datasets'), path('projects//datasets//remove/', RemoveDatasetView.as_view(), diff --git a/vitrina/requests/urls.py b/vitrina/requests/urls.py index 5b944c2e..ea9dcba2 100644 --- a/vitrina/requests/urls.py +++ b/vitrina/requests/urls.py @@ -11,7 +11,7 @@ # @GetMapping("/requests/info") # @GetMapping("/requests/request") path('requests/add/', RequestCreateView.as_view(), name='request-create'), - path('requests//change/', RequestUpdateView.as_view(), name='request-update'), + path('requests//update/', RequestUpdateView.as_view(), name='request-update'), path('requests//history/', RequestHistoryView.as_view(), name='request-history'), # @PostMapping("/request") # @PostMapping("/requests/new") diff --git a/vitrina/resources/urls.py b/vitrina/resources/urls.py index 0cc2b3d8..c2f49bf2 100644 --- a/vitrina/resources/urls.py +++ b/vitrina/resources/urls.py @@ -4,7 +4,7 @@ urlpatterns = [ path('resource//add', ResourceCreateView.as_view(), name='resource-add'), - path('resource//change', ResourceUpdateView.as_view(), name='resource-change'), - path('resource//delete', ResourceDeleteView.as_view(), name='resource-delete'), + path('resource//update', ResourceUpdateView.as_view(), name='resource-update'), + path('resource//remove', ResourceDeleteView.as_view(), name='resource-remove'), # @GetMapping("/resources") ] diff --git a/vitrina/users/templates/vitrina/users/profile.html b/vitrina/users/templates/vitrina/users/profile.html index 5fe6009f..3af65bea 100644 --- a/vitrina/users/templates/vitrina/users/profile.html +++ b/vitrina/users/templates/vitrina/users/profile.html @@ -80,7 +80,7 @@

{{ user.first_name }} {{ user.last_name }}