-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change "object_id" to be a "CharField" (#138)
* [-] CrudEvent object_id as a `CharField` * [-] Use `pk` instead of `id` in pre_save object lookup * [-] Fixes issue w/ post_delete / Adds delete test * [-] Adds updates from #141 PR * [-] Removes the need for an explicit query - Uses the internal `_state` object * [-] Adds `_state` compat test * [-] Removes sqlite3 test db
- Loading branch information
Showing
9 changed files
with
226 additions
and
25 deletions.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.0.6 on 2020-05-13 00:08 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('easyaudit', '0013_auto_20190723_0126'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='crudevent', | ||
name='object_id', | ||
field=models.CharField(max_length=255), | ||
), | ||
] |
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
Binary file not shown.
61 changes: 61 additions & 0 deletions
61
...tforeignkey_testbigintm2m_testbigintmodel_testuuidforeignkey_testuuidm2m_testuuidmodel.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,61 @@ | ||
# Generated by Django 3.0.6 on 2020-05-14 17:28 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('test_app', '0002_auto_20180220_1533'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='TestBigIntModel', | ||
fields=[ | ||
('id', models.BigAutoField(primary_key=True, serialize=False)), | ||
('name', models.CharField(default='test data', max_length=50)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='TestUUIDModel', | ||
fields=[ | ||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)), | ||
('name', models.CharField(default='test data', max_length=50)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='TestUUIDM2M', | ||
fields=[ | ||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)), | ||
('name', models.CharField(max_length=50)), | ||
('test_m2m', models.ManyToManyField(to='test_app.TestUUIDModel')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='TestUUIDForeignKey', | ||
fields=[ | ||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)), | ||
('name', models.CharField(max_length=50)), | ||
('test_fk', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='test_app.TestUUIDModel')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='TestBigIntM2M', | ||
fields=[ | ||
('id', models.BigAutoField(primary_key=True, serialize=False)), | ||
('name', models.CharField(max_length=50)), | ||
('test_m2m', models.ManyToManyField(to='test_app.TestBigIntModel')), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='TestBigIntForeignKey', | ||
fields=[ | ||
('id', models.BigAutoField(primary_key=True, serialize=False)), | ||
('name', models.CharField(max_length=50)), | ||
('test_fk', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='test_app.TestBigIntModel')), | ||
], | ||
), | ||
] |
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
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 |
---|---|---|
@@ -1,13 +1,48 @@ | ||
from datetime import datetime | ||
|
||
from django.http import HttpResponse | ||
from test_app.models import TestModel | ||
from test_app.models import TestModel, TestUUIDModel, TestBigIntModel | ||
|
||
|
||
def create_obj(Model): | ||
return Model.objects.create() | ||
|
||
|
||
def update_obj(Model, pk, name): | ||
tm = Model.objects.get(pk=pk) | ||
tm.name = name | ||
tm.save() | ||
return tm | ||
|
||
|
||
def create_obj_view(request): | ||
return HttpResponse(TestModel.objects.create().id) | ||
return HttpResponse(create_obj(TestModel).id) | ||
|
||
|
||
def update_obj_view(request): | ||
tm = TestModel.objects.get(pk=request.GET['id']) | ||
tm.name = request.GET['id'] | ||
tm.save() | ||
return HttpResponse(tm.id) | ||
name = datetime.now().isoformat() | ||
return HttpResponse(update_obj( | ||
TestModel, request.GET['id'], name | ||
).id) | ||
|
||
|
||
def create_uuid_obj_view(request): | ||
return HttpResponse(create_obj(TestUUIDModel).id) | ||
|
||
|
||
def update_uuid_obj_view(request): | ||
name = datetime.now().isoformat() | ||
return HttpResponse(update_obj( | ||
TestUUIDModel, request.GET['id'], name | ||
).id) | ||
|
||
|
||
def create_big_obj_view(request): | ||
return HttpResponse(create_obj(TestBigIntModel).id) | ||
|
||
|
||
def update_big_obj_view(request): | ||
name = datetime.now().isoformat() | ||
return HttpResponse(update_obj( | ||
TestBigIntModel, request.GET['id'], name | ||
).id) |