-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from incuna/remove-django-pgcrypto-fields
Remove django-pgcrypto-fields.
- Loading branch information
Showing
12 changed files
with
139 additions
and
102 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
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,5 +1,9 @@ | ||
# Changelog | ||
|
||
Upcoming | ||
|
||
* BREAKING CHANGE: Remove django-pgcrypto-fields. | ||
|
||
### v0.1.0 | ||
|
||
* Add LogEntry model, together with a supporting serializer and view mixins. |
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
35 changes: 35 additions & 0 deletions
35
model_logging/migrations/0001_squashed_0004_remove_old_field.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,35 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.utils.timezone | ||
from django.conf import settings | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
replaces = [('model_logging', '0001_initial'), ('model_logging', '0002_add_new_data_field'), ('model_logging', '0003_data_migration'), ('model_logging', '0004_remove_old_field')] | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='LogEntry', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, verbose_name='ID', serialize=False)), | ||
('date_created', models.DateTimeField(default=django.utils.timezone.now)), | ||
('operation', models.CharField(max_length=255, choices=[('added', 'Added'), ('removed', 'Removed'), ('modified', 'Modified')])), | ||
('model_path', models.CharField(max_length=255)), | ||
('data', models.TextField(default='')), | ||
('creator', models.ForeignKey(related_name='log_entries_created', to=settings.AUTH_USER_MODEL, null=True)), | ||
('user', models.ForeignKey(related_name='log_entries', to=settings.AUTH_USER_MODEL, null=True)), | ||
], | ||
options={ | ||
'ordering': ('date_created',), | ||
}, | ||
), | ||
] |
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,21 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
from django.conf import settings | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('model_logging', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='LogEntry', | ||
name='data_temp', | ||
field=models.TextField(default=''), | ||
), | ||
] |
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,38 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.db import migrations | ||
|
||
app = 'model_logging' | ||
model = 'LogEntry' | ||
|
||
|
||
def move_data(apps, schema_editor): | ||
try: | ||
from pgcrypto.fields import TextPGPPublicKeyField | ||
except ImportError: | ||
raise ImportError('Please install django-pgcrypto-fields to perform migration') | ||
|
||
LogEntry = apps.get_model(app, model) | ||
for entry in LogEntry.objects.all(): | ||
entry.data_temp = entry.data | ||
entry.save() | ||
|
||
def move_data_back(apps, schema_editor): | ||
try: | ||
from pgcrypto.fields import TextPGPPublicKeyField | ||
except ImportError: | ||
raise ImportError('Please install django-pgcrypto-fields to perform migration') | ||
|
||
LogEntry = apps.get_model(app, model) | ||
for entry in LogEntry.objects.all(): | ||
entry.data = entry.data_temp | ||
entry.save() | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('model_logging', '0002_add_new_data_field'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(move_data, reverse_code=move_data_back), | ||
] |
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,25 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
from django.conf import settings | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('model_logging', '0003_data_migration'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='LogEntry', | ||
name='data', | ||
), | ||
migrations.RenameField( | ||
model_name='LogEntry', | ||
old_name='data_temp', | ||
new_name='data', | ||
), | ||
] |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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