Merge lp:~ricardokirkner/django-adminaudit/1188250-getting-bigger into lp:django-adminaudit

Proposed by Ricardo Kirkner
Status: Merged
Approved by: Natalia Bidart
Approved revision: 57
Merged at revision: 52
Proposed branch: lp:~ricardokirkner/django-adminaudit/1188250-getting-bigger
Merge into: lp:django-adminaudit
Prerequisite: lp:~ricardokirkner/django-adminaudit/going-south
Diff against target: 127 lines (+83/-4)
4 files modified
adminaudit/migrations/0002_auto__chg_field_auditlog_username__chg_field_auditlog_representation__.py (+46/-0)
adminaudit/models.py (+3/-3)
adminaudit/tests.py (+33/-0)
setup.py (+1/-1)
To merge this branch: bzr merge lp:~ricardokirkner/django-adminaudit/1188250-getting-bigger
Reviewer Review Type Date Requested Status
Matias Bordese (community) Approve
Review via email: mp+168151@code.launchpad.net

Commit message

removed size constraints from username, model and representation fields

Description of the change

This branch removes size constraints on certain AuditLog columns. This should fix bug # when deployed.

As sqlite will happily ignore constraints, tests needed to be smarted about it. They are inspired by this post: http://stackoverflow.com/questions/8478054/django-model-charfield-max-length-does-not-work

To post a comment you must log in.
Revision history for this message
Matias Bordese (matiasb) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'adminaudit/migrations/0002_auto__chg_field_auditlog_username__chg_field_auditlog_representation__.py'
2--- adminaudit/migrations/0002_auto__chg_field_auditlog_username__chg_field_auditlog_representation__.py 1970-01-01 00:00:00 +0000
3+++ adminaudit/migrations/0002_auto__chg_field_auditlog_username__chg_field_auditlog_representation__.py 2013-06-07 19:09:29 +0000
4@@ -0,0 +1,46 @@
5+# -*- coding: utf-8 -*-
6+import datetime
7+from south.db import db
8+from south.v2 import SchemaMigration
9+from django.db import models
10+
11+
12+class Migration(SchemaMigration):
13+
14+ def forwards(self, orm):
15+
16+ # Changing field 'AuditLog.username'
17+ db.alter_column(u'adminaudit_auditlog', 'username', self.gf('django.db.models.fields.TextField')())
18+
19+ # Changing field 'AuditLog.representation'
20+ db.alter_column(u'adminaudit_auditlog', 'representation', self.gf('django.db.models.fields.TextField')())
21+
22+ # Changing field 'AuditLog.model'
23+ db.alter_column(u'adminaudit_auditlog', 'model', self.gf('django.db.models.fields.TextField')())
24+
25+ def backwards(self, orm):
26+
27+ # Changing field 'AuditLog.username'
28+ db.alter_column(u'adminaudit_auditlog', 'username', self.gf('django.db.models.fields.CharField')(max_length=255))
29+
30+ # Changing field 'AuditLog.representation'
31+ db.alter_column(u'adminaudit_auditlog', 'representation', self.gf('django.db.models.fields.CharField')(max_length=255))
32+
33+ # Changing field 'AuditLog.model'
34+ db.alter_column(u'adminaudit_auditlog', 'model', self.gf('django.db.models.fields.CharField')(max_length=255))
35+
36+ models = {
37+ u'adminaudit.auditlog': {
38+ 'Meta': {'object_name': 'AuditLog'},
39+ 'change': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
40+ 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
41+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
42+ 'model': ('django.db.models.fields.TextField', [], {}),
43+ 'representation': ('django.db.models.fields.TextField', [], {}),
44+ 'user_id': ('django.db.models.fields.IntegerField', [], {}),
45+ 'username': ('django.db.models.fields.TextField', [], {}),
46+ 'values': ('django.db.models.fields.TextField', [], {})
47+ }
48+ }
49+
50+ complete_apps = ['adminaudit']
51\ No newline at end of file
52
53=== modified file 'adminaudit/models.py'
54--- adminaudit/models.py 2012-08-21 17:39:18 +0000
55+++ adminaudit/models.py 2013-06-07 19:09:29 +0000
56@@ -12,11 +12,11 @@
57 Records of all changes made via Django admin interface.
58
59 """
60- username = models.CharField(max_length=255)
61+ username = models.TextField()
62 user_id = models.IntegerField()
63- model = models.CharField(max_length=255)
64+ model = models.TextField()
65 change = models.CharField(max_length=100)
66- representation = models.CharField(max_length=255)
67+ representation = models.TextField()
68 values = models.TextField()
69 created_at = models.DateTimeField(auto_now_add=True)
70
71
72=== modified file 'adminaudit/tests.py'
73--- adminaudit/tests.py 2012-04-26 16:39:32 +0000
74+++ adminaudit/tests.py 2013-06-07 19:09:29 +0000
75@@ -44,6 +44,39 @@
76 self.client.login(username='test', password='test')
77
78
79+class AuditLogTestCase(TestCase):
80+ def make_log_data(self, **overrides):
81+ data = {
82+ 'username': 'test',
83+ 'user_id': 1,
84+ 'model': 'model',
85+ 'change': 'change',
86+ 'representation': 'representation',
87+ 'values': 'values',
88+ }
89+ data.update(overrides)
90+ return data
91+
92+ def assert_log_valid(self, data):
93+ log = AuditLog(**data)
94+ # force model validation
95+ # full_clean raises a ValidationError if object doesn't validate with
96+ # model.
97+ log.full_clean()
98+
99+ def test_long_username(self):
100+ data = self.make_log_data(username='a'*500)
101+ self.assert_log_valid(data)
102+
103+ def test_long_model(self):
104+ data = self.make_log_data(model='a'*500)
105+ self.assert_log_valid(data)
106+
107+ def test_long_representation(self):
108+ data = self.make_log_data(representation='a'*500)
109+ self.assert_log_valid(data)
110+
111+
112 class AuditAdminEmailReportTestCase(TestCase):
113
114 def create_and_log_in_user(self, **kwargs):
115
116=== modified file 'setup.py'
117--- setup.py 2013-06-07 19:09:29 +0000
118+++ setup.py 2013-06-07 19:09:29 +0000
119@@ -27,7 +27,7 @@
120 setup(
121 # metadata
122 name='django-adminaudit',
123- version='0.3.4',
124+ version='0.4.0',
125 description="Extends Django's admin logging capabilities",
126 url='https://launchpad.net/django-adminaudit',
127 author='Łukasz Czyżykowski',

Subscribers

People subscribed via source and target branches