-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes string primary keys quotes #117
Open
insspb
wants to merge
7
commits into
burke-software:master
Choose a base branch
from
insspb:fix-quoting
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0f29019
Fixes string primary keys quotes
insspb 2d77eff
Fix imports
insspb 825d8d6
Fix tests migrations
insspb 7156e4d
Unquote all ids in a batch, instead only one
insspb 3f0707c
Update changelog
insspb 0f0f65b
Add tests for string pk
insspb 53e949d
Exclude db.sqlite3 from accidental push
insspb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ django_mass_edit.egg-info | |
.idea | ||
.coverage | ||
.tox | ||
db.sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
tests/migrations/0003_fieldsetsadminmodel_alter_customadminmodel_id_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Generated by Django 4.2.5 on 2023-09-19 09:17 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("tests", "0002_auto_20211217_0041"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="FieldsetsAdminModel", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("first_name", models.CharField(max_length=32)), | ||
("middle_name", models.CharField(max_length=32)), | ||
("last_name", models.CharField(max_length=32)), | ||
], | ||
), | ||
migrations.AlterField( | ||
model_name="customadminmodel", | ||
name="id", | ||
field=models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="customadminmodel2", | ||
name="id", | ||
field=models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="inheritedadminmodel", | ||
name="id", | ||
field=models.AutoField( | ||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID" | ||
), | ||
), | ||
] |
22 changes: 22 additions & 0 deletions
22
tests/migrations/0004_add_model_with_string_primary_key.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Generated by Django 4.2.5 on 2023-09-19 10:36 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("tests", "0003_fieldsetsadminmodel_alter_customadminmodel_id_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="StringAdminModel", | ||
fields=[ | ||
( | ||
"primary", | ||
models.CharField(max_length=32, primary_key=True, serialize=False), | ||
), | ||
("name", models.CharField(max_length=32)), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
from django.contrib.auth.models import User | ||
from django.contrib import admin | ||
from django.test import TestCase, override_settings, RequestFactory | ||
|
||
try: | ||
from django.urls import reverse | ||
except ImportError: # Django<2.0 | ||
|
@@ -14,6 +15,7 @@ | |
CustomAdminModel2, | ||
InheritedAdminModel, | ||
FieldsetsAdminModel, | ||
StringAdminModel, | ||
) | ||
from .site import CustomAdminSite | ||
from .mocks import MockRenderMassAdmin | ||
|
@@ -76,6 +78,20 @@ def test_update(self, admin_name='admin'): | |
# all models have changed | ||
self.assertEqual(list(new_names), ["new name"] * 3) | ||
|
||
def test_update_with_string_primary_key_and_special_chars(self, admin_name='admin'): | ||
models = [StringAdminModel.objects.create( | ||
primary="{}/3".format(1 + i), | ||
name="model {}".format(i), | ||
) for i in range(0, 3)] | ||
|
||
response = self.client.post(get_massadmin_url(models, self.client.session), | ||
{"_mass_change": "name", | ||
"name": "new name"}) | ||
self.assertRedirects(response, get_changelist_url(StringAdminModel, admin_name)) | ||
new_names = StringAdminModel.objects.order_by("pk").values_list("name", flat=True) | ||
# all models have changed | ||
self.assertEqual(list(new_names), ["new name"] * 3) | ||
|
||
@override_settings(ROOT_URLCONF='tests.urls_custom_admin') | ||
def test_custom_admin_site_update(self): | ||
""" We test_update for a custom admin on top of a regular as well | ||
|
@@ -164,6 +180,7 @@ def test_excluded_queryset(self): | |
class CustomizationTestCase(TestCase): | ||
""" MassAdmin has all customized options from related ModelAdmin | ||
""" | ||
|
||
def setUp(self): | ||
self.user = User.objects.create_superuser( | ||
'temporary', '[email protected]', 'temporary') | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.