Page MenuHomeSoftware Heritage

[wip] [fail] Install app_label on add_forge_now model classes
AbandonedPublicDraft

Authored by ardumont on Mar 29 2022, 12:29 PM.

Details

Reviewers
None
Group Reviewers
Reviewers
Summary

This does not make any sense and does not work at all...

See [1] for context

[1] D7446#194413

Diff Detail

Repository
rDWAPPS Web applications
Branch
fix-doc-build
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 27895
Build 43678: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 43677: arc lint + arc unit

Unit TestsFailed

TimeTest
572 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.web.tests.add_forge_now.test_views::test_add_forge_request_list_datatables
client = <django.test.client.Client object at 0x7fac584e4828> regular_user = <User: johndoe>, regular_user2 = <User: janedoe> add_forge_moderator = <User: add-forge moderator>
388 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.web.tests.add_forge_now.test_views::test_add_forge_request_list_datatables_no_parameters
client = <django.test.client.Client object at 0x7fac5747db38> regular_user = <User: johndoe>, regular_user2 = <User: janedoe>
377 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.web.tests.add_forge_now.test_views::test_add_forge_request_list_datatables_ordering
client = <django.test.client.Client object at 0x7fac5730edd8> regular_user = <User: johndoe>, regular_user2 = <User: janedoe>
391 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.web.tests.add_forge_now.test_views::test_add_forge_request_list_datatables_search
client = <django.test.client.Client object at 0x7fac56b96c88> regular_user = <User: johndoe>, regular_user2 = <User: janedoe>
386 msJenkins > .tox.py3.lib.python3.7.site-packages.swh.web.tests.add_forge_now.test_views::test_add_forge_request_list_datatables_user_requests
client = <django.test.client.Client object at 0x7fac5699fac8> regular_user = <User: johndoe>, regular_user2 = <User: janedoe>
View Full Test Results (24 Failed · 680 Passed · 5 Skipped)

Event Timeline

Build has FAILED

Patch application report for D7452 (id=26979)

Could not rebase; Attempt merge onto 4bc8aaf1d9...

Updating 4bc8aaf1..d1e2d99d
Fast-forward
 swh/web/add_forge_now/apps.py                            |  4 +++-
 .../add_forge_now/migrations/0004_auto_20220329_1026.py  | 16 ++++++++++++++++
 swh/web/add_forge_now/models.py                          | 10 ++++++++++
 swh/web/inbound_email/management/__init__.py             |  0
 swh/web/inbound_email/management/commands/__init__.py    |  0
 5 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 swh/web/add_forge_now/migrations/0004_auto_20220329_1026.py
 create mode 100644 swh/web/inbound_email/management/__init__.py
 create mode 100644 swh/web/inbound_email/management/commands/__init__.py
Changes applied before test
commit d1e2d99dbe99870d441e2e076c8259fc7192785e
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Tue Mar 29 12:28:48 2022 +0200

    [wip] [fail] Install app_label on add_forge_now model classes
    
    This does not work at all...

commit 0c1e63d70261d917be5f4c3400772c6864e6cb56
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Tue Mar 29 09:50:12 2022 +0200

    swh.web.inbound_email: Add missing __init__.py file
    
    My hypothesis is that those missing files are making the swh-docs build fail.
    That's the only difference i see between those swh.web folders and the rest.

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1619/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/1619/console

Harbormaster returned this revision to the author for changes because remote builds failed.Mar 29 2022, 12:52 PM
Harbormaster failed remote builds in B27895: Diff 26979!

That app label mess is because we are using django 2.x and we miss to declare the default_app_config in swh/web/add_forge_now/__init__.py.

This is how you can fix this. Please note that the app label has been updated in existing migrations now its is correctly taken into account.
Fortunately, those migrations have not been executed in production.

diff --git a/swh/web/add_forge_now/__init__.py b/swh/web/add_forge_now/__init__.py
index e69de29b..f27e23ec 100644
--- a/swh/web/add_forge_now/__init__.py
+++ b/swh/web/add_forge_now/__init__.py
@@ -0,0 +1,6 @@
+# Copyright (C) 2022  The Software Heritage developers
+# See the AUTHORS file at the top-level directory of this distribution
+# License: GNU Affero General Public License version 3, or any later version
+# See top-level LICENSE file for more information
+
+default_app_config = "swh.web.add_forge_now.apps.AddForgeNowConfig"
diff --git a/swh/web/add_forge_now/migrations/0001_initial.py b/swh/web/add_forge_now/migrations/0001_initial.py
index c049a13b..dfed76b2 100644
--- a/swh/web/add_forge_now/migrations/0001_initial.py
+++ b/swh/web/add_forge_now/migrations/0001_initial.py
@@ -101,7 +101,7 @@ class Migration(migrations.Migration):
                     "request",
                     models.ForeignKey(
                         on_delete=django.db.models.deletion.DO_NOTHING,
-                        to="add_forge_now.Request",
+                        to="swh_web_add_forge_now.Request",
                     ),
                 ),
             ],
diff --git a/swh/web/add_forge_now/migrations/0002_authorized_null_comment.py b/swh/web/add_forge_now/migrations/0002_authorized_null_comment.py
index 0c02e2ff..713c993f 100644
--- a/swh/web/add_forge_now/migrations/0002_authorized_null_comment.py
+++ b/swh/web/add_forge_now/migrations/0002_authorized_null_comment.py
@@ -6,7 +6,7 @@ from django.db import migrations, models
 class Migration(migrations.Migration):
 
     dependencies = [
-        ("add_forge_now", "0001_initial"),
+        ("swh_web_add_forge_now", "0001_initial"),
     ]
 
     operations = [
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
index d6b0a841..4e639841 100644
--- 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
@@ -6,7 +6,7 @@ from django.db import migrations, models
 class Migration(migrations.Migration):
 
     dependencies = [
-        ("add_forge_now", "0002_authorized_null_comment"),
+        ("swh_web_add_forge_now", "0002_authorized_null_comment"),
     ]
 
     operations = [
diff --git a/swh/web/add_forge_now/migrations/0004_rename_tables.py b/swh/web/add_forge_now/migrations/0004_rename_tables.py
new file mode 100644
index 00000000..2d59e835
--- /dev/null
+++ b/swh/web/add_forge_now/migrations/0004_rename_tables.py
@@ -0,0 +1,21 @@
+# Generated by Django 2.2.27 on 2022-03-29 11:42
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('swh_web_add_forge_now', '0003_request_submitter_forward_username'),
+    ]
+
+    operations = [
+        migrations.AlterModelTable(
+            name='request',
+            table='add_forge_request',
+        ),
+        migrations.AlterModelTable(
+            name='requesthistory',
+            table='add_forge_request_history',
+        ),
+    ]
diff --git a/swh/web/add_forge_now/models.py b/swh/web/add_forge_now/models.py
index 5f9f0603..3d667a43 100644
--- a/swh/web/add_forge_now/models.py
+++ b/swh/web/add_forge_now/models.py
@@ -81,6 +81,10 @@ class RequestHistory(models.Model):
     date = models.DateTimeField(auto_now_add=True)
     new_status = models.TextField(choices=RequestStatus.choices(), null=True)
 
+    class Meta:
+        app_label = "swh_web_add_forge_now"
+        db_table = "add_forge_request_history"
+
 
 class Request(models.Model):
     status = models.TextField(
@@ -98,3 +102,7 @@ class Request(models.Model):
     forge_contact_comment = models.TextField(
         null=True, help_text="Where did you find this contact information (url, ...)",
     )
+
+    class Meta:
+        app_label = "swh_web_add_forge_now"
+        db_table = "add_forge_request"
swh/web/add_forge_now/migrations/0004_auto_20220329_1026.py
12–16

This migration drops the tables for the add forge now django apps, this is not what we want.

swh/web/add_forge_now/models.py
88

I would rather name the table add_forge_request_history instead.

110

s/request/add_forge_request/

I'm gonna close this one and update the previous one (linked in the description) with your patch, thx.

swh/web/add_forge_now/migrations/0004_auto_20220329_1026.py
12–16

yeah, i know, see the linked context in the description.

swh/web/add_forge_now/models.py
88

sure, i thought that was the initial name...