Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123206
D7446.id27059.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Subscribers
None
D7446.id27059.diff
View Options
diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js
--- a/cypress/plugins/index.js
+++ b/cypress/plugins/index.js
@@ -150,7 +150,7 @@
'db:add_forge_now:delete': () => {
const db = getDatabase();
db.serialize(function() {
- db.run('DELETE FROM add_forge_now_request');
+ db.run('DELETE FROM add_forge_request');
});
db.close();
return true;
diff --git a/swh/web/add_forge_now/__init__.py b/swh/web/add_forge_now/__init__.py
--- 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/apps.py b/swh/web/add_forge_now/apps.py
--- a/swh/web/add_forge_now/apps.py
+++ b/swh/web/add_forge_now/apps.py
@@ -5,7 +5,9 @@
from django.apps import AppConfig
+APP_LABEL = "swh_web_add_forge_now"
+
class AddForgeNowConfig(AppConfig):
name = "swh.web.add_forge_now"
- label = "swh_web_add_forge_now"
+ label = APP_LABEL
diff --git a/swh/web/add_forge_now/migrations/0001_initial.py b/swh/web/add_forge_now/migrations/0001_initial.py
--- a/swh/web/add_forge_now/migrations/0001_initial.py
+++ b/swh/web/add_forge_now/migrations/0001_initial.py
@@ -101,7 +101,7 @@
"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
--- 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 @@
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
--- 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 @@
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
--- /dev/null
+++ b/swh/web/add_forge_now/migrations/0004_rename_tables.py
@@ -0,0 +1,17 @@
+# 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
--- a/swh/web/add_forge_now/models.py
+++ b/swh/web/add_forge_now/models.py
@@ -10,6 +10,8 @@
from django.db import models
+from .apps import APP_LABEL
+
class RequestStatus(enum.Enum):
"""Request statuses.
@@ -81,6 +83,10 @@
date = models.DateTimeField(auto_now_add=True)
new_status = models.TextField(choices=RequestStatus.choices(), null=True)
+ class Meta:
+ app_label = APP_LABEL
+ db_table = "add_forge_request_history"
+
class Request(models.Model):
status = models.TextField(
@@ -98,3 +104,7 @@
forge_contact_comment = models.TextField(
null=True, help_text="Where did you find this contact information (url, ...)",
)
+
+ class Meta:
+ app_label = APP_LABEL
+ db_table = "add_forge_request"
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
@@ -7,7 +7,7 @@
import pytest
-APP_NAME = "add_forge_now"
+from swh.web.add_forge_now.apps import APP_LABEL
MIGRATION_0001 = "0001_initial"
MIGRATION_0002 = "0002_authorized_null_comment"
@@ -21,9 +21,9 @@
def test_add_forge_now_initial_migration(migrator):
"""Basic migration test to check the model is fine"""
- state = migrator.apply_tested_migration((APP_NAME, MIGRATION_0001))
- request = state.apps.get_model(APP_NAME, "Request")
- request_history = state.apps.get_model(APP_NAME, "RequestHistory")
+ state = migrator.apply_tested_migration((APP_LABEL, MIGRATION_0001))
+ request = state.apps.get_model(APP_LABEL, "Request")
+ request_history = state.apps.get_model(APP_LABEL, "RequestHistory")
from swh.web.add_forge_now.models import RequestActorRole, RequestStatus
@@ -71,7 +71,7 @@
from django.db.utils import IntegrityError
- state = migrator.apply_tested_migration((APP_NAME, MIGRATION_0001))
+ state = migrator.apply_tested_migration((APP_LABEL, MIGRATION_0001))
def make_request_with_empty_comment(requestModel):
return requestModel(
@@ -85,14 +85,14 @@
forge_contact_comment=None,
)
- requestModel = state.apps.get_model(APP_NAME, "Request")
+ requestModel = state.apps.get_model(APP_LABEL, "Request")
req = make_request_with_empty_comment(requestModel)
with pytest.raises(IntegrityError, match="violates not-null constraint"):
req.save()
- state = migrator.apply_tested_migration((APP_NAME, MIGRATION_0002))
- requestModel2 = state.apps.get_model(APP_NAME, "Request")
+ state = migrator.apply_tested_migration((APP_LABEL, MIGRATION_0002))
+ requestModel2 = state.apps.get_model(APP_LABEL, "Request")
req2 = make_request_with_empty_comment(requestModel2)
req2.save()
@@ -101,11 +101,11 @@
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")
+ state = migrator.apply_tested_migration((APP_LABEL, MIGRATION_0002))
+ requestModel = state.apps.get_model(APP_LABEL, "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")
+ state = migrator.apply_tested_migration((APP_LABEL, MIGRATION_0003))
+ requestModel2 = state.apps.get_model(APP_LABEL, "Request")
assert hasattr(requestModel2, "submitter_forward_username")
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 18, 2:54 AM (1 d, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3215977
Attached To
D7446: Install app_label on add_forge_now model classes
Event Timeline
Log In to Comment