From ea2e497bf50d135a099e999caace24c4d0598a28 Mon Sep 17 00:00:00 2001 From: cmsetzer <37311998+cmsetzer@users.noreply.github.com> Date: Fri, 6 Sep 2024 11:14:13 -0800 Subject: [PATCH] Prune old code for Journals/Faculty sign-ups (#3599) * Prune old code for Journals/Faculty sign-ups * Remove now-extraneous import --- .../settings/deployments/settings_common.py | 2 - .../registration/sign-up-faculty.html | 49 ----- .../registration/sign-up-journals.html | 49 ----- .../perma/tests/test_views_user_management.py | 196 ------------------ perma_web/perma/urls.py | 2 - perma_web/perma/views/user_management.py | 51 ----- 6 files changed, 349 deletions(-) delete mode 100644 perma_web/perma/templates/registration/sign-up-faculty.html delete mode 100644 perma_web/perma/templates/registration/sign-up-journals.html diff --git a/perma_web/perma/settings/deployments/settings_common.py b/perma_web/perma/settings/deployments/settings_common.py index b17ec1b72..e748b17a0 100644 --- a/perma_web/perma/settings/deployments/settings_common.py +++ b/perma_web/perma/settings/deployments/settings_common.py @@ -612,8 +612,6 @@ 'dev_docs', 'sign_up', 'sign_up_courts', - 'sign_up_faculty', - 'sign_up_journals', 'sign_up_firm', 'libraries' ] diff --git a/perma_web/perma/templates/registration/sign-up-faculty.html b/perma_web/perma/templates/registration/sign-up-faculty.html deleted file mode 100644 index 9c8a25155..000000000 --- a/perma_web/perma/templates/registration/sign-up-faculty.html +++ /dev/null @@ -1,49 +0,0 @@ -{% extends "base-responsive.html" %} - -{% block meta_description %}Perma.cc for faculty{% endblock %} - -{% block bodyFlags %}_signup _faculty{% endblock %} -{% block mainFlags %}{% endblock %} - -{% block mainContent %} -
-
-
-

Perma.cc for faculty

-

Scholarship depends on accurate, reliable citations to stable sources. When web citations break, or the referenced content changes, that undermines good scholarship.

-
-
-
- -{% include "registration/includes/sign-up-navigation.html" with this_page="faculty" %} - -
-
- -
-

Perma.cc for faculty

-

Faculty use Perma.cc to prevent link rot in their scholarship.

- -

Free and easy to use

-

For faculty associated with a registrar library, Perma.cc is free. It is easy to use, and you can authorize others, such as assistants and researchers, to preserve sources on your behalf.

- -

Bluebook compliant

-

The Bluebook now encourages archiving online sources when a reliable service such as Perma.cc is available.

- -

Contact your library for a journal account

-

If your library is already registered with us, contact them for setup. If not, invite your library to visit our library resource page to request membership, and we’ll help them get started.

- -

Try it now

-

Users not associated with a registrar library must sign up for a paid subscription. New users can create 10 Perma Links for free to try out the service. Create an account now to start your free trial. Your library will be able to upgrade your individual account at a later date.

-

-
-
-{% endblock mainContent %} diff --git a/perma_web/perma/templates/registration/sign-up-journals.html b/perma_web/perma/templates/registration/sign-up-journals.html deleted file mode 100644 index 97d8588d2..000000000 --- a/perma_web/perma/templates/registration/sign-up-journals.html +++ /dev/null @@ -1,49 +0,0 @@ -{% extends "base-responsive.html" %} - -{% block meta_description %}Perma.cc for journals{% endblock %} - -{% block bodyFlags %}_signup _journals{% endblock %} -{% block mainFlags %}{% endblock %} - -{% block mainContent %} -
-
-
-

Perma.cc for journals

-

Over 150 academic law journals prevent link rot with Perma.cc.

-
-
-
- -{% include "registration/includes/sign-up-navigation.html" with this_page="journals" %} - -
-
- -
-

Perma.cc for journals

-

Over 150 academic law journals prevent link rot with Perma.cc.

- -

Free and easy to use

-

Perma.cc is easy to use and free for any academic journal that is authorized by its library. Our user guide has more details on how Perma.cc works for journals.

- -

Bluebook compliant

-

The Bluebook now encourages archiving online sources when a reliable service such as Perma.cc is available.

- -

Contact your library for a journal account

-

If your library is already registered with us, contact them for setup. If not, invite your library to visit our library resource page to request membership, and we’ll help them get started.

- -

Try it now

-

Users not associated with a registrar library must sign up for a paid subscription. New users can create 10 Perma Links for free to try out the service. Create an account now to start your free trial. Your library will be able to connect this account to your journal’s account at a later date.

-

-
-
-{% endblock mainContent %} diff --git a/perma_web/perma/tests/test_views_user_management.py b/perma_web/perma/tests/test_views_user_management.py index 553f86ed2..45232395d 100644 --- a/perma_web/perma/tests/test_views_user_management.py +++ b/perma_web/perma/tests/test_views_user_management.py @@ -2442,202 +2442,6 @@ def test_new_firm_failure(self): ) self.assertEqual(len(mail.outbox), 0) - ### Journals ### - - def new_journal(self): - rand = random() - return { 'requested_account_note': 'Journal {}'.format(rand)} - - def new_journal_user(self): - rand = random() - email = self.randomize_capitalization('user{}@university.org'.format(rand)) - return { 'raw_email': email, - 'normalized_email': email.lower(), - 'first': 'Joe', - 'last': 'Yacobówski' } - - @override_settings(REQUIRE_JS_FORM_SUBMISSIONS=False) - def test_new_journal_success(self): - ''' - Does the journal signup form submit as expected? Success cases. - ''' - new_journal = self.new_journal() - new_user = self.new_journal_user() - existing_user = {'email': 'test_user@example.com'} - expected_emails_sent = 0 - - # NOT LOGGED IN - - # New user email address + journal info - self.submit_form('sign_up_journals', - data = { 'e-address': new_user['raw_email'], - 'requested_account_note': new_journal['requested_account_note']}, - success_url = reverse('register_email_instructions')) - expected_emails_sent += 1 - self.assertEqual(len(mail.outbox), expected_emails_sent) - self.check_new_activation_email(mail.outbox[expected_emails_sent - 1], new_user['raw_email']) - - # LOGGED IN - - # New user email address + journal info - # (This succeeds and creates a new account; see issue 1749) - new_user = self.new_journal_user() - self.submit_form('sign_up_journals', - data = { 'e-address': new_user['raw_email'], - 'requested_account_note': new_journal['requested_account_note']}, - user = existing_user['email'], - success_url = reverse('register_email_instructions')) - expected_emails_sent += 1 - self.assertEqual(len(mail.outbox), expected_emails_sent) - self.check_new_activation_email(mail.outbox[expected_emails_sent - 1], new_user['raw_email']) - - @override_settings(REQUIRE_JS_FORM_SUBMISSIONS=False) - def test_new_journal_form_honeypot(self): - new_journal = self.new_journal() - new_user = self.new_journal_user() - self.submit_form('sign_up_journals', - data = { 'e-address': new_user['raw_email'], - 'requested_account_note': new_journal['requested_account_note'], - 'telephone': "I'm a bot." }, - success_url = reverse('register_email_instructions')) - self.assertEqual(len(mail.outbox), 0) - self.assertFalse(LinkUser.objects.filter(email__iexact=new_user['raw_email']).exists()) - - @override_settings(REQUIRE_JS_FORM_SUBMISSIONS=False) - def test_new_journal_failure(self): - ''' - Does the journal signup form submit as expected? Failure cases. - ''' - - # NOT LOGGED IN - - # Blank submission reports correct fields required - self.submit_form('sign_up_journals', - data = {}, - error_keys = ['email', 'requested_account_note']) - self.assertEqual(len(mail.outbox), 0) - - # If email address already belongs to an account, validation fails - self.submit_form('sign_up_journals', - data = { 'e-address': self.randomize_capitalization('test_user@example.com'), - 'requested_account_note': 'Here'}, - error_keys = ['email']) - self.assertEqual(len(mail.outbox), 0) - - # LOGGED IN - # (This is odd; see issue 1749) - - # Blank submission reports correct fields required - self.submit_form('sign_up_journals', - data = {}, - user = 'test_user@example.com', - error_keys = ['email', 'requested_account_note']) - self.assertEqual(len(mail.outbox), 0) - - # If email address already belongs to an account, validation fails - self.submit_form('sign_up_journals', - data = { 'e-address': self.randomize_capitalization('test_user@example.com'), - 'requested_account_note': 'Here'}, - user = 'test_user@example.com', - error_keys = ['email']) - self.assertEqual(len(mail.outbox), 0) - - - ### Faculty ### - - def new_faculty_user(self): - rand = random() - email = self.randomize_capitalization('user{}@university.org'.format(rand)) - return { 'raw_email': email, - 'normalized_email': email.lower(), - 'first': 'Joe', - 'last': 'Yacobówski', - 'requested_account_note': 'Journal {}'.format(rand) } - - @override_settings(REQUIRE_JS_FORM_SUBMISSIONS=False) - def test_new_faculty_success(self): - ''' - Does the faculty signup form submit as expected? Success cases. - ''' - new_user = self.new_faculty_user() - existing_user = {'email': 'test_user@example.com'} - expected_emails_sent = 0 - - # NOT LOGGED IN - - # New user email address + journal info - self.submit_form('sign_up_faculty', - data = { 'e-address': new_user['raw_email'], - 'requested_account_note': new_user['requested_account_note']}, - success_url = reverse('register_email_instructions')) - expected_emails_sent += 1 - self.assertEqual(len(mail.outbox), expected_emails_sent) - self.check_new_activation_email(mail.outbox[expected_emails_sent - 1], new_user['raw_email']) - - # LOGGED IN - - # New user email address + journal info - # (This succeeds and creates a new account; see issue 1749) - new_user = self.new_faculty_user() - self.submit_form('sign_up_faculty', - data = { 'e-address': new_user['raw_email'], - 'requested_account_note': new_user['requested_account_note']}, - user = existing_user['email'], - success_url = reverse('register_email_instructions')) - expected_emails_sent += 1 - self.assertEqual(len(mail.outbox), expected_emails_sent) - self.check_new_activation_email(mail.outbox[expected_emails_sent - 1], new_user['raw_email']) - - @override_settings(REQUIRE_JS_FORM_SUBMISSIONS=False) - def test_new_faculty_form_honeypot(self): - new_user = self.new_faculty_user() - self.submit_form('sign_up_faculty', - data = { 'e-address': new_user['raw_email'], - 'requested_account_note': new_user['requested_account_note'], - 'telephone': "I'm a bot." }, - success_url = reverse('register_email_instructions')) - self.assertEqual(len(mail.outbox), 0) - self.assertFalse(LinkUser.objects.filter(email__iexact=new_user['raw_email']).exists()) - - @override_settings(REQUIRE_JS_FORM_SUBMISSIONS=False) - def test_new_faculty_failure(self): - ''' - Does the faculty signup form submit as expected? Failure cases. - ''' - - # NOT LOGGED IN - - # Blank submission reports correct fields required - self.submit_form('sign_up_faculty', - data = {}, - error_keys = ['email', 'requested_account_note']) - self.assertEqual(len(mail.outbox), 0) - - # If email address already belongs to an account, validation fails - self.submit_form('sign_up_faculty', - data = { 'e-address': self.randomize_capitalization('test_user@example.com'), - 'requested_account_note': 'Here'}, - error_keys = ['email']) - self.assertEqual(len(mail.outbox), 0) - - # LOGGED IN - # (This is odd; see issue 1749) - - # Blank submission reports correct fields required - self.submit_form('sign_up_faculty', - data = {}, - user = 'test_user@example.com', - error_keys = ['email', 'requested_account_note']) - self.assertEqual(len(mail.outbox), 0) - - # If email address already belongs to an account, validation fails - self.submit_form('sign_up_faculty', - data = { 'e-address': self.randomize_capitalization('test_user@example.com'), - 'requested_account_note': 'Here'}, - user = 'test_user@example.com', - error_keys = ['email']) - self.assertEqual(len(mail.outbox), 0) - ### Individual Users ### def check_new_activation_email(self, message, user_email): diff --git a/perma_web/perma/urls.py b/perma_web/perma/urls.py index ebb759671..59b2e2cfd 100755 --- a/perma_web/perma/urls.py +++ b/perma_web/perma/urls.py @@ -55,8 +55,6 @@ re_path(r'^sign-up/?$', user_management.sign_up, name='sign_up'), re_path(r'^sign-up/courts/?$', user_management.sign_up_courts, name='sign_up_courts'), - re_path(r'^sign-up/faculty/?$', user_management.sign_up_faculty, name='sign_up_faculty'), - re_path(r'^sign-up/journals/?$', user_management.sign_up_journals, name='sign_up_journals'), re_path(r'^sign-up/firms/?$', user_management.sign_up_firm, name='sign_up_firm'), re_path(r'^libraries/?$', user_management.libraries, name='libraries'), diff --git a/perma_web/perma/views/user_management.py b/perma_web/perma/views/user_management.py index 5411d013e..4003a1dff 100755 --- a/perma_web/perma/views/user_management.py +++ b/perma_web/perma/views/user_management.py @@ -60,7 +60,6 @@ UserFormWithOrganization, CreateUserFormWithCourt, CreateUserFormWithFirm, - CreateUserFormWithUniversity, UserAddRegistrarForm, UserAddSponsoringRegistrarForm, UserAddOrganizationForm, @@ -1871,31 +1870,6 @@ def sign_up_courts(request): return render(request, "registration/sign-up-courts.html", {'form': form}) -@ratelimit(rate=settings.REGISTER_MINUTE_LIMIT, block=True, key=ratelimit_ip_key) -def sign_up_faculty(request): - """ - Register a new user - """ - if request.method == 'POST': - - if something_took_the_bait := check_honeypot(request, 'register_email_instructions', check_js=True): - return something_took_the_bait - - form = CreateUserFormWithUniversity(request.POST) - if form.is_valid(): - new_user = form.save(commit=False) - new_user.requested_account_type = 'faculty' - new_user.save() - - email_new_user(request, new_user) - - messages.add_message(request, messages.INFO, "Remember to ask your library about access to special Perma.cc privileges.") - return HttpResponseRedirect(reverse('register_email_instructions')) - else: - form = CreateUserFormWithUniversity() - - return render(request, "registration/sign-up-faculty.html", {'form': form}) - @ratelimit(rate=settings.REGISTER_MINUTE_LIMIT, block=True, key=ratelimit_ip_key) def sign_up_firm(request): """ @@ -1964,31 +1938,6 @@ def sign_up_firm(request): ) -@ratelimit(rate=settings.REGISTER_MINUTE_LIMIT, block=True, key=ratelimit_ip_key) -def sign_up_journals(request): - """ - Register a new user - """ - if request.method == 'POST': - - if something_took_the_bait := check_honeypot(request, 'register_email_instructions', check_js=True): - return something_took_the_bait - - form = CreateUserFormWithUniversity(request.POST) - if form.is_valid(): - new_user = form.save(commit=False) - new_user.requested_account_type = 'journal' - new_user.save() - - email_new_user(request, new_user) - - messages.add_message(request, messages.INFO, "Remember to ask your library about access to special Perma.cc privileges.") - return HttpResponseRedirect(reverse('register_email_instructions')) - else: - form = CreateUserFormWithUniversity() - - return render(request, "registration/sign-up-journals.html", {'form': form}) - def register_email_instructions(request): """ After the user has registered, give the instructions for confirming