diff --git a/cypress/integration/add-forge-now-request-create.spec.js b/cypress/integration/add-forge-now-request-create.spec.js --- a/cypress/integration/add-forge-now-request-create.spec.js +++ b/cypress/integration/add-forge-now-request-create.spec.js @@ -11,6 +11,7 @@ cy.get('#swh-input-forge-contact-name').type(contact); cy.get('#swh-input-forge-contact-email').type(email); cy.get('#swh-input-forge-comment').type(comment); + cy.get('#swh-input-consent-check').click({force: consent === 'on'}); } describe('Test add-forge-request creation', function() { @@ -152,7 +153,7 @@ cy.visit(this.addForgeNowUrl); populateForm( - 'bitbucket', 'gitlab.com', 'test', 'test@example.com', 'on', 'comment' + 'bitbucket', 'gitlab.com', 'test', 'test@example.com', 'off', 'comment' ); cy.get('#requestCreateForm').submit(); diff --git a/swh/web/add_forge_now/migrations/0003_request_submitter_forward_username.py b/swh/web/add_forge_now/migrations/0003_request_submitter_forward_username.py new file mode 100644 --- /dev/null +++ b/swh/web/add_forge_now/migrations/0003_request_submitter_forward_username.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.24 on 2022-03-21 16:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("add_forge_now", "0002_authorized_null_comment"), + ] + + operations = [ + migrations.AddField( + model_name="request", + name="submitter_forward_username", + field=models.BooleanField(default=False), + ), + ] diff --git a/swh/web/add_forge_now/models.py b/swh/web/add_forge_now/models.py --- a/swh/web/add_forge_now/models.py +++ b/swh/web/add_forge_now/models.py @@ -89,6 +89,7 @@ submission_date = models.DateTimeField(auto_now_add=True) submitter_name = models.TextField() submitter_email = models.TextField() + submitter_forward_username = models.BooleanField(default=False) # FIXME: shall we do create a user model inside the webapp instead? forge_type = models.TextField() forge_url = models.TextField() diff --git a/swh/web/add_forge_now/tests/test_migration.py b/swh/web/add_forge_now/tests/test_migration.py --- a/swh/web/add_forge_now/tests/test_migration.py +++ b/swh/web/add_forge_now/tests/test_migration.py @@ -11,6 +11,7 @@ MIGRATION_0001 = "0001_initial" MIGRATION_0002 = "0002_authorized_null_comment" +MIGRATION_0003 = "0003_request_submitter_forward_username" def now() -> datetime: @@ -95,3 +96,16 @@ req2 = make_request_with_empty_comment(requestModel2) req2.save() + + +def test_add_forge_now_store_submitter_forward_username(migrator): + """Basic migration test to check new model authorized empty comment""" + + state = migrator.apply_tested_migration((APP_NAME, MIGRATION_0002)) + requestModel = state.apps.get_model(APP_NAME, "Request") + assert not hasattr(requestModel, "submitter_forward_username") + + state = migrator.apply_tested_migration((APP_NAME, MIGRATION_0003)) + requestModel2 = state.apps.get_model(APP_NAME, "Request") + + assert hasattr(requestModel2, "submitter_forward_username") diff --git a/swh/web/api/views/add_forge_now.py b/swh/web/api/views/add_forge_now.py --- a/swh/web/api/views/add_forge_now.py +++ b/swh/web/api/views/add_forge_now.py @@ -45,6 +45,7 @@ "forge_contact_email", "forge_contact_name", "forge_contact_comment", + "submitter_forward_username", ) diff --git a/swh/web/templates/add_forge_now/create-request.html b/swh/web/templates/add_forge_now/create-request.html --- a/swh/web/templates/add_forge_now/create-request.html +++ b/swh/web/templates/add_forge_now/create-request.html @@ -104,9 +104,9 @@