Merge lp:~widelands-dev/widelands-website/cleanup_ip_address_field into lp:widelands-website
- cleanup_ip_address_field
- Merge into trunk
Proposed by
kaputtnik
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 502 | ||||
Proposed branch: | lp:~widelands-dev/widelands-website/cleanup_ip_address_field | ||||
Merge into: | lp:widelands-website | ||||
Diff against target: |
429 lines (+87/-47) 16 files modified
pybb/admin.py (+1/-1) pybb/forms.py (+1/-2) pybb/migrations/0003_remove_post_user_ip.py (+19/-0) pybb/models.py (+0/-1) pybb/views.py (+1/-2) templates/wiki/edit.html (+0/-1) templates/wiki/history.html (+0/-4) wiki/admin.py (+2/-8) wiki/forms.py (+2/-6) wiki/migrations/0003_auto_20180918_0836.py (+27/-0) wiki/models.py (+7/-10) wiki/views.py (+3/-5) wlimages/admin.py (+1/-1) wlimages/migrations/0003_remove_image_editor_ip.py (+19/-0) wlimages/models.py (+3/-4) wlimages/views.py (+1/-2) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands-website/cleanup_ip_address_field | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Widelands Developers | Pending | ||
Review via email: mp+356061@code.launchpad.net |
Commit message
Remove the use of an IPAddressField from wiki, wlimages and pybb
Description of the change
As far i can see the IPAddressField was stored without a specific reason, except allowing to post anonymously, which we don't allow at all.
This branch removes that field from wiki, wlimages and pybb.
Removing this field from threadedcomments will be done in a different branch, because the changes are too big for this branch.
To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote : | # |
Revision history for this message
kaputtnik (franku) wrote : | # |
Thanks for the review :-)
The classes are just used to show collapsed sections. They show up as "More options (Show)" like here: https:/
Sorry for the remaining print statement. I'll remove it and merge this then.
Revision history for this message
kaputtnik (franku) wrote : | # |
The changes are applied, but not committed yet. Will do it this evening...
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'pybb/admin.py' | |||
2 | --- pybb/admin.py 2017-04-29 19:52:28 +0000 | |||
3 | +++ pybb/admin.py 2018-10-03 20:25:29 +0000 | |||
4 | @@ -84,7 +84,7 @@ | |||
5 | 84 | ), | 84 | ), |
6 | 85 | (_('Additional options'), { | 85 | (_('Additional options'), { |
7 | 86 | 'classes': ('collapse',), | 86 | 'classes': ('collapse',), |
9 | 87 | 'fields': (('created', 'updated'), 'user_ip') | 87 | 'fields': (('created', 'updated'),) |
10 | 88 | } | 88 | } |
11 | 89 | ), | 89 | ), |
12 | 90 | (_('Message'), { | 90 | (_('Message'), { |
13 | 91 | 91 | ||
14 | === modified file 'pybb/forms.py' | |||
15 | --- pybb/forms.py 2018-04-07 09:48:02 +0000 | |||
16 | +++ pybb/forms.py 2018-10-03 20:25:29 +0000 | |||
17 | @@ -25,7 +25,6 @@ | |||
18 | 25 | self.user = kwargs.pop('user', None) | 25 | self.user = kwargs.pop('user', None) |
19 | 26 | self.topic = kwargs.pop('topic', None) | 26 | self.topic = kwargs.pop('topic', None) |
20 | 27 | self.forum = kwargs.pop('forum', None) | 27 | self.forum = kwargs.pop('forum', None) |
21 | 28 | self.ip = kwargs.pop('ip', None) | ||
22 | 29 | super(AddPostForm, self).__init__(*args, **kwargs) | 28 | super(AddPostForm, self).__init__(*args, **kwargs) |
23 | 30 | 29 | ||
24 | 31 | if self.topic: | 30 | if self.topic: |
25 | @@ -54,7 +53,7 @@ | |||
26 | 54 | topic_is_new = False | 53 | topic_is_new = False |
27 | 55 | topic = self.topic | 54 | topic = self.topic |
28 | 56 | 55 | ||
30 | 57 | post = Post(topic=topic, user=self.user, user_ip=self.ip, | 56 | post = Post(topic=topic, user=self.user, |
31 | 58 | markup=self.cleaned_data['markup'], | 57 | markup=self.cleaned_data['markup'], |
32 | 59 | body=self.cleaned_data['body']) | 58 | body=self.cleaned_data['body']) |
33 | 60 | post.save(*args, **kwargs) | 59 | post.save(*args, **kwargs) |
34 | 61 | 60 | ||
35 | === added file 'pybb/migrations/0003_remove_post_user_ip.py' | |||
36 | --- pybb/migrations/0003_remove_post_user_ip.py 1970-01-01 00:00:00 +0000 | |||
37 | +++ pybb/migrations/0003_remove_post_user_ip.py 2018-10-03 20:25:29 +0000 | |||
38 | @@ -0,0 +1,19 @@ | |||
39 | 1 | # -*- coding: utf-8 -*- | ||
40 | 2 | # Generated by Django 1.11.12 on 2018-10-02 19:31 | ||
41 | 3 | from __future__ import unicode_literals | ||
42 | 4 | |||
43 | 5 | from django.db import migrations | ||
44 | 6 | |||
45 | 7 | |||
46 | 8 | class Migration(migrations.Migration): | ||
47 | 9 | |||
48 | 10 | dependencies = [ | ||
49 | 11 | ('pybb', '0002_auto_20161001_2046'), | ||
50 | 12 | ] | ||
51 | 13 | |||
52 | 14 | operations = [ | ||
53 | 15 | migrations.RemoveField( | ||
54 | 16 | model_name='post', | ||
55 | 17 | name='user_ip', | ||
56 | 18 | ), | ||
57 | 19 | ] | ||
58 | 0 | 20 | ||
59 | === modified file 'pybb/models.py' | |||
60 | --- pybb/models.py 2018-04-08 14:40:17 +0000 | |||
61 | +++ pybb/models.py 2018-10-03 20:25:29 +0000 | |||
62 | @@ -203,7 +203,6 @@ | |||
63 | 203 | body = models.TextField(_('Message')) | 203 | body = models.TextField(_('Message')) |
64 | 204 | body_html = models.TextField(_('HTML version')) | 204 | body_html = models.TextField(_('HTML version')) |
65 | 205 | body_text = models.TextField(_('Text version')) | 205 | body_text = models.TextField(_('Text version')) |
66 | 206 | user_ip = models.GenericIPAddressField(_('User IP'), default='') | ||
67 | 207 | hidden = models.BooleanField(_('Hidden'), blank=True, default=False) | 206 | hidden = models.BooleanField(_('Hidden'), blank=True, default=False) |
68 | 208 | 207 | ||
69 | 209 | class Meta: | 208 | class Meta: |
70 | 210 | 209 | ||
71 | === modified file 'pybb/views.py' | |||
72 | --- pybb/views.py 2018-04-08 14:40:17 +0000 | |||
73 | +++ pybb/views.py 2018-10-03 20:25:29 +0000 | |||
74 | @@ -20,7 +20,6 @@ | |||
75 | 20 | from pybb import settings as pybb_settings | 20 | from pybb import settings as pybb_settings |
76 | 21 | from pybb.orm import load_related | 21 | from pybb.orm import load_related |
77 | 22 | 22 | ||
78 | 23 | from wl_utils import get_real_ip | ||
79 | 24 | from check_input.models import SuspiciousInput | 23 | from check_input.models import SuspiciousInput |
80 | 25 | 24 | ||
81 | 26 | try: | 25 | try: |
82 | @@ -154,7 +153,7 @@ | |||
83 | 154 | quote = quote_text(post.body, post.user, 'markdown') | 153 | quote = quote_text(post.body, post.user, 'markdown') |
84 | 155 | 154 | ||
85 | 156 | form = build_form(AddPostForm, request, topic=topic, forum=forum, | 155 | form = build_form(AddPostForm, request, topic=topic, forum=forum, |
87 | 157 | user=request.user, ip=get_real_ip(request), | 156 | user=request.user, |
88 | 158 | initial={'markup': 'markdown', 'body': quote}) | 157 | initial={'markup': 'markdown', 'body': quote}) |
89 | 159 | 158 | ||
90 | 160 | if form.is_valid(): | 159 | if form.is_valid(): |
91 | 161 | 160 | ||
92 | === modified file 'templates/wiki/edit.html' | |||
93 | --- templates/wiki/edit.html 2017-01-15 12:03:04 +0000 | |||
94 | +++ templates/wiki/edit.html 2018-10-03 20:25:29 +0000 | |||
95 | @@ -77,7 +77,6 @@ | |||
96 | 77 | {{ form.content_type }} | 77 | {{ form.content_type }} |
97 | 78 | {{ form.object_id }} | 78 | {{ form.object_id }} |
98 | 79 | {{ form.action }} | 79 | {{ form.action }} |
99 | 80 | {{ form.user_ip }} | ||
100 | 81 | 80 | ||
101 | 82 | <div> | 81 | <div> |
102 | 83 | <input id="id_preview" type="button" value="{% trans "Preview" %}" /> | 82 | <input id="id_preview" type="button" value="{% trans "Preview" %}" /> |
103 | 84 | 83 | ||
104 | === modified file 'templates/wiki/history.html' | |||
105 | --- templates/wiki/history.html 2016-04-26 16:10:04 +0000 | |||
106 | +++ templates/wiki/history.html 2018-10-03 20:25:29 +0000 | |||
107 | @@ -99,11 +99,7 @@ | |||
108 | 99 | {{ change.modified|custom_date:user }} | 99 | {{ change.modified|custom_date:user }} |
109 | 100 | </td> | 100 | </td> |
110 | 101 | <td> | 101 | <td> |
111 | 102 | {% if change.is_anonymous_change %} | ||
112 | 103 | {{ change.editor_ip }} | ||
113 | 104 | {% else %} | ||
114 | 105 | {{ change.editor|user_link }} | 102 | {{ change.editor|user_link }} |
115 | 106 | {% endif %} | ||
116 | 107 | </td> | 103 | </td> |
117 | 108 | <td class="italic"> | 104 | <td class="italic"> |
118 | 109 | {% if change.comment %}'{{ change.comment }}'{% endif %} | 105 | {% if change.comment %}'{{ change.comment }}'{% endif %} |
119 | 110 | 106 | ||
120 | === modified file 'wiki/admin.py' | |||
121 | --- wiki/admin.py 2017-12-03 11:43:47 +0000 | |||
122 | +++ wiki/admin.py 2018-10-03 20:25:29 +0000 | |||
123 | @@ -21,11 +21,7 @@ | |||
124 | 21 | list_filter = ('title',) | 21 | list_filter = ('title',) |
125 | 22 | ordering = ['-last_update'] | 22 | ordering = ['-last_update'] |
126 | 23 | fieldsets = ( | 23 | fieldsets = ( |
132 | 24 | (None, {'fields': ('title', 'content', 'markup')}), | 24 | (None, {'fields': ('title', 'content', 'creator', 'markup')}), |
128 | 25 | ('Creator', {'fields': ('creator', 'creator_ip'), | ||
129 | 26 | 'classes': ('collapse', 'wide')}), | ||
130 | 27 | # ('Group', {'fields': ('object_id', 'content_type'), | ||
131 | 28 | # 'classes': ('collapse', 'wide')}), | ||
133 | 29 | ) | 25 | ) |
134 | 30 | raw_id_fields = ('creator',) | 26 | raw_id_fields = ('creator',) |
135 | 31 | inlines = [InlineImages] | 27 | inlines = [InlineImages] |
136 | @@ -41,13 +37,11 @@ | |||
137 | 41 | list_filter = ('article__title',) | 37 | list_filter = ('article__title',) |
138 | 42 | ordering = ('-modified',) | 38 | ordering = ('-modified',) |
139 | 43 | fieldsets = ( | 39 | fieldsets = ( |
141 | 44 | ('Article', {'fields': ('article',)}), | 40 | ('Article', {'fields': ('article', 'editor')}), |
142 | 45 | ('Differences', {'fields': ('old_title', 'old_markup', | 41 | ('Differences', {'fields': ('old_title', 'old_markup', |
143 | 46 | 'content_diff')}), | 42 | 'content_diff')}), |
144 | 47 | ('Other', {'fields': ('comment', 'modified', 'revision', 'reverted'), | 43 | ('Other', {'fields': ('comment', 'modified', 'revision', 'reverted'), |
145 | 48 | 'classes': ('collapse', 'wide')}), | 44 | 'classes': ('collapse', 'wide')}), |
146 | 49 | ('Editor', {'fields': ('editor', 'editor_ip'), | ||
147 | 50 | 'classes': ('collapse', 'wide')}), | ||
148 | 51 | ) | 45 | ) |
149 | 52 | raw_id_fields = ('editor',) | 46 | raw_id_fields = ('editor',) |
150 | 53 | 47 | ||
151 | 54 | 48 | ||
152 | === modified file 'wiki/forms.py' | |||
153 | --- wiki/forms.py 2017-04-29 19:56:32 +0000 | |||
154 | +++ wiki/forms.py 2018-10-03 20:25:29 +0000 | |||
155 | @@ -22,7 +22,6 @@ | |||
156 | 22 | summary = forms.CharField(widget=forms.Textarea) | 22 | summary = forms.CharField(widget=forms.Textarea) |
157 | 23 | 23 | ||
158 | 24 | comment = forms.CharField(required=False) | 24 | comment = forms.CharField(required=False) |
159 | 25 | user_ip = forms.CharField(widget=forms.HiddenInput) | ||
160 | 26 | 25 | ||
161 | 27 | content_type = forms.ModelChoiceField( | 26 | content_type = forms.ModelChoiceField( |
162 | 28 | queryset=ContentType.objects.all(), | 27 | queryset=ContentType.objects.all(), |
163 | @@ -35,8 +34,7 @@ | |||
164 | 35 | 34 | ||
165 | 36 | class Meta: | 35 | class Meta: |
166 | 37 | model = Article | 36 | model = Article |
169 | 38 | exclude = ('creator', 'creator_ip', | 37 | exclude = ('creator', 'group', 'created_at', 'last_update') |
168 | 39 | 'group', 'created_at', 'last_update') | ||
170 | 40 | 38 | ||
171 | 41 | def clean_title(self): | 39 | def clean_title(self): |
172 | 42 | """Check for some errors regarding the title: | 40 | """Check for some errors regarding the title: |
173 | @@ -92,7 +90,6 @@ | |||
174 | 92 | 90 | ||
175 | 93 | def save(self, *args, **kwargs): | 91 | def save(self, *args, **kwargs): |
176 | 94 | # 0 - Extra data | 92 | # 0 - Extra data |
177 | 95 | editor_ip = self.cleaned_data['user_ip'] | ||
178 | 96 | comment = self.cleaned_data['comment'] | 93 | comment = self.cleaned_data['comment'] |
179 | 97 | 94 | ||
180 | 98 | # 2 - Save the Article | 95 | # 2 - Save the Article |
181 | @@ -102,7 +99,6 @@ | |||
182 | 102 | editor = getattr(self, 'editor', None) | 99 | editor = getattr(self, 'editor', None) |
183 | 103 | group = getattr(self, 'group', None) | 100 | group = getattr(self, 'group', None) |
184 | 104 | if self.is_new: | 101 | if self.is_new: |
185 | 105 | article.creator_ip = editor_ip | ||
186 | 106 | if editor is not None: | 102 | if editor is not None: |
187 | 107 | article.creator = editor | 103 | article.creator = editor |
188 | 108 | article.group = group | 104 | article.group = group |
189 | @@ -113,6 +109,6 @@ | |||
190 | 113 | # 4 - Create new revision | 109 | # 4 - Create new revision |
191 | 114 | changeset = article.new_revision( | 110 | changeset = article.new_revision( |
192 | 115 | self.old_content, self.old_title, self.old_markup, | 111 | self.old_content, self.old_title, self.old_markup, |
194 | 116 | comment, editor_ip, editor) | 112 | comment, editor) |
195 | 117 | 113 | ||
196 | 118 | return article, changeset | 114 | return article, changeset |
197 | 119 | 115 | ||
198 | === added file 'wiki/migrations/0003_auto_20180918_0836.py' | |||
199 | --- wiki/migrations/0003_auto_20180918_0836.py 1970-01-01 00:00:00 +0000 | |||
200 | +++ wiki/migrations/0003_auto_20180918_0836.py 2018-10-03 20:25:29 +0000 | |||
201 | @@ -0,0 +1,27 @@ | |||
202 | 1 | # -*- coding: utf-8 -*- | ||
203 | 2 | # Generated by Django 1.11.12 on 2018-09-18 08:36 | ||
204 | 3 | from __future__ import unicode_literals | ||
205 | 4 | |||
206 | 5 | from django.db import migrations | ||
207 | 6 | |||
208 | 7 | |||
209 | 8 | class Migration(migrations.Migration): | ||
210 | 9 | |||
211 | 10 | dependencies = [ | ||
212 | 11 | ('wiki', '0002_auto_20161218_1056'), | ||
213 | 12 | ] | ||
214 | 13 | |||
215 | 14 | operations = [ | ||
216 | 15 | migrations.AlterModelOptions( | ||
217 | 16 | name='article', | ||
218 | 17 | options={'default_permissions': ('change', 'add'), 'ordering': ['title'], 'verbose_name': 'Article', 'verbose_name_plural': 'Articles'}, | ||
219 | 18 | ), | ||
220 | 19 | migrations.RemoveField( | ||
221 | 20 | model_name='article', | ||
222 | 21 | name='creator_ip', | ||
223 | 22 | ), | ||
224 | 23 | migrations.RemoveField( | ||
225 | 24 | model_name='changeset', | ||
226 | 25 | name='editor_ip', | ||
227 | 26 | ), | ||
228 | 27 | ] | ||
229 | 0 | 28 | ||
230 | === modified file 'wiki/models.py' | |||
231 | --- wiki/models.py 2018-05-02 06:33:13 +0000 | |||
232 | +++ wiki/models.py 2018-10-03 20:25:29 +0000 | |||
233 | @@ -53,8 +53,6 @@ | |||
234 | 53 | null=True, blank=True) | 53 | null=True, blank=True) |
235 | 54 | creator = models.ForeignKey(User, verbose_name=_('Article Creator'), | 54 | creator = models.ForeignKey(User, verbose_name=_('Article Creator'), |
236 | 55 | null=True) | 55 | null=True) |
237 | 56 | creator_ip = models.GenericIPAddressField(_('IP Address of the Article Creator'), | ||
238 | 57 | blank=True, null=True) | ||
239 | 58 | created_at = models.DateTimeField(default=datetime.now) | 56 | created_at = models.DateTimeField(default=datetime.now) |
240 | 59 | last_update = models.DateTimeField(blank=True, null=True) | 57 | last_update = models.DateTimeField(blank=True, null=True) |
241 | 60 | 58 | ||
242 | @@ -93,7 +91,7 @@ | |||
243 | 93 | return self.images.all() | 91 | return self.images.all() |
244 | 94 | 92 | ||
245 | 95 | def new_revision(self, old_content, old_title, old_markup, | 93 | def new_revision(self, old_content, old_title, old_markup, |
247 | 96 | comment, editor_ip, editor): | 94 | comment, editor): |
248 | 97 | """Create a new ChangeSet with the old content.""" | 95 | """Create a new ChangeSet with the old content.""" |
249 | 98 | 96 | ||
250 | 99 | content_diff = diff(self.content, old_content) | 97 | content_diff = diff(self.content, old_content) |
251 | @@ -101,7 +99,6 @@ | |||
252 | 101 | cs = ChangeSet.objects.create( | 99 | cs = ChangeSet.objects.create( |
253 | 102 | article=self, | 100 | article=self, |
254 | 103 | comment=comment, | 101 | comment=comment, |
255 | 104 | editor_ip=editor_ip, | ||
256 | 105 | editor=editor, | 102 | editor=editor, |
257 | 106 | old_title=old_title, | 103 | old_title=old_title, |
258 | 107 | old_markup=old_markup, | 104 | old_markup=old_markup, |
259 | @@ -109,10 +106,10 @@ | |||
260 | 109 | 106 | ||
261 | 110 | return cs | 107 | return cs |
262 | 111 | 108 | ||
264 | 112 | def revert_to(self, revision, editor_ip, editor=None): | 109 | def revert_to(self, revision, editor=None): |
265 | 113 | """Revert the article to a previuos state, by revision number.""" | 110 | """Revert the article to a previuos state, by revision number.""" |
266 | 114 | changeset = self.changeset_set.get(revision=revision) | 111 | changeset = self.changeset_set.get(revision=revision) |
268 | 115 | changeset.reapply(editor_ip, editor) | 112 | changeset.reapply(editor) |
269 | 116 | 113 | ||
270 | 117 | def compare(self, from_revision, to_revision): | 114 | def compare(self, from_revision, to_revision): |
271 | 118 | """Compares to revisions of this article.""" | 115 | """Compares to revisions of this article.""" |
272 | @@ -139,10 +136,9 @@ | |||
273 | 139 | 136 | ||
274 | 140 | article = models.ForeignKey(Article, verbose_name=_(u"Article")) | 137 | article = models.ForeignKey(Article, verbose_name=_(u"Article")) |
275 | 141 | 138 | ||
277 | 142 | # Editor identification -- logged or anonymous | 139 | # Editor identification -- logged |
278 | 143 | editor = models.ForeignKey(User, verbose_name=_(u'Editor'), | 140 | editor = models.ForeignKey(User, verbose_name=_(u'Editor'), |
279 | 144 | null=True) | 141 | null=True) |
280 | 145 | editor_ip = models.GenericIPAddressField(_(u"IP Address of the Editor")) | ||
281 | 146 | 142 | ||
282 | 147 | # Revision number, starting from 1 | 143 | # Revision number, starting from 1 |
283 | 148 | revision = models.IntegerField(_(u"Revision Number")) | 144 | revision = models.IntegerField(_(u"Revision Number")) |
284 | @@ -185,7 +181,7 @@ | |||
285 | 185 | def is_anonymous_change(self): | 181 | def is_anonymous_change(self): |
286 | 186 | return self.editor is None | 182 | return self.editor is None |
287 | 187 | 183 | ||
289 | 188 | def reapply(self, editor_ip, editor): | 184 | def reapply(self, editor): |
290 | 189 | """Return the Article to this revision.""" | 185 | """Return the Article to this revision.""" |
291 | 190 | 186 | ||
292 | 191 | # XXX Would be better to exclude reverted revisions | 187 | # XXX Would be better to exclude reverted revisions |
293 | @@ -218,7 +214,8 @@ | |||
294 | 218 | old_content=old_content, old_title=old_title, | 214 | old_content=old_content, old_title=old_title, |
295 | 219 | old_markup=old_markup, | 215 | old_markup=old_markup, |
296 | 220 | comment='Reverted to revision #%s' % self.revision, | 216 | comment='Reverted to revision #%s' % self.revision, |
298 | 221 | editor_ip=editor_ip, editor=editor) | 217 | editor=editor |
299 | 218 | ) | ||
300 | 222 | 219 | ||
301 | 223 | self.save() | 220 | self.save() |
302 | 224 | 221 | ||
303 | 225 | 222 | ||
304 | === modified file 'wiki/views.py' | |||
305 | --- wiki/views.py 2018-04-08 14:40:17 +0000 | |||
306 | +++ wiki/views.py 2018-10-03 20:25:29 +0000 | |||
307 | @@ -300,15 +300,13 @@ | |||
308 | 300 | return redirect(new_article) | 300 | return redirect(new_article) |
309 | 301 | 301 | ||
310 | 302 | elif request.method == 'GET': | 302 | elif request.method == 'GET': |
311 | 303 | user_ip = get_real_ip(request) | ||
312 | 304 | 303 | ||
313 | 305 | # TODO(Franku): Never worked IMHO | 304 | # TODO(Franku): Never worked IMHO |
314 | 306 | # lock = cache.get(title, None) | 305 | # lock = cache.get(title, None) |
315 | 307 | # if lock is None: | 306 | # if lock is None: |
316 | 308 | # lock = ArticleEditLock(title, request) | 307 | # lock = ArticleEditLock(title, request) |
317 | 309 | # lock.create_message(request) | 308 | # lock.create_message(request) |
320 | 310 | 309 | initial = {} | |
319 | 311 | initial = {'user_ip': user_ip} | ||
321 | 312 | if group_slug is not None: | 310 | if group_slug is not None: |
322 | 313 | initial.update({'content_type': group_ct.id, | 311 | initial.update({'content_type': group_ct.id, |
323 | 314 | 'object_id': group.id}) | 312 | 'object_id': group.id}) |
324 | @@ -493,9 +491,9 @@ | |||
325 | 493 | except Article.DoesNotExist: | 491 | except Article.DoesNotExist: |
326 | 494 | # No existing article found -> reverting possible | 492 | # No existing article found -> reverting possible |
327 | 495 | if request.user.is_authenticated: | 493 | if request.user.is_authenticated: |
329 | 496 | article.revert_to(revision, get_real_ip(request), request.user) | 494 | article.revert_to(revision, request.user) |
330 | 497 | else: | 495 | else: |
332 | 498 | article.revert_to(revision, get_real_ip(request)) | 496 | article.revert_to(revision) |
333 | 499 | return redirect(article) | 497 | return redirect(article) |
334 | 500 | # An article with this name exists | 498 | # An article with this name exists |
335 | 501 | messages.error( | 499 | messages.error( |
336 | 502 | 500 | ||
337 | === modified file 'wlimages/admin.py' | |||
338 | --- wlimages/admin.py 2016-12-13 18:28:51 +0000 | |||
339 | +++ wlimages/admin.py 2018-10-03 20:25:29 +0000 | |||
340 | @@ -31,7 +31,7 @@ | |||
341 | 31 | actions = [delete_with_file] | 31 | actions = [delete_with_file] |
342 | 32 | fieldsets = ( | 32 | fieldsets = ( |
343 | 33 | (None, {'fields': ('image', 'name', 'date_submitted', 'revision')}), | 33 | (None, {'fields': ('image', 'name', 'date_submitted', 'revision')}), |
345 | 34 | (_('Upload data:'), {'fields': ('user', 'editor_ip')}), | 34 | (_('Uploaded by:'), {'fields': ('user',)}), |
346 | 35 | (_('Content object:'), { | 35 | (_('Content object:'), { |
347 | 36 | 'fields': (('content_type', 'content_object'), 'object_id')}), | 36 | 'fields': (('content_type', 'content_object'), 'object_id')}), |
348 | 37 | ) | 37 | ) |
349 | 38 | 38 | ||
350 | === added file 'wlimages/migrations/0003_remove_image_editor_ip.py' | |||
351 | --- wlimages/migrations/0003_remove_image_editor_ip.py 1970-01-01 00:00:00 +0000 | |||
352 | +++ wlimages/migrations/0003_remove_image_editor_ip.py 2018-10-03 20:25:29 +0000 | |||
353 | @@ -0,0 +1,19 @@ | |||
354 | 1 | # -*- coding: utf-8 -*- | ||
355 | 2 | # Generated by Django 1.11.12 on 2018-09-18 09:01 | ||
356 | 3 | from __future__ import unicode_literals | ||
357 | 4 | |||
358 | 5 | from django.db import migrations | ||
359 | 6 | |||
360 | 7 | |||
361 | 8 | class Migration(migrations.Migration): | ||
362 | 9 | |||
363 | 10 | dependencies = [ | ||
364 | 11 | ('wlimages', '0002_remove_image_url'), | ||
365 | 12 | ] | ||
366 | 13 | |||
367 | 14 | operations = [ | ||
368 | 15 | migrations.RemoveField( | ||
369 | 16 | model_name='image', | ||
370 | 17 | name='editor_ip', | ||
371 | 18 | ), | ||
372 | 19 | ] | ||
373 | 0 | 20 | ||
374 | === modified file 'wlimages/models.py' | |||
375 | --- wlimages/models.py 2016-12-13 18:28:51 +0000 | |||
376 | +++ wlimages/models.py 2018-10-03 20:25:29 +0000 | |||
377 | @@ -24,6 +24,7 @@ | |||
378 | 24 | def create(self, **keyw): | 24 | def create(self, **keyw): |
379 | 25 | """Makes sure that no image/revision pair is already in the | 25 | """Makes sure that no image/revision pair is already in the |
380 | 26 | database.""" | 26 | database.""" |
381 | 27 | |||
382 | 27 | if 'name' not in keyw or 'revision' not in keyw: | 28 | if 'name' not in keyw or 'revision' not in keyw: |
383 | 28 | raise IntegrityError('needs name and revision as keywords') | 29 | raise IntegrityError('needs name and revision as keywords') |
384 | 29 | 30 | ||
385 | @@ -32,12 +33,12 @@ | |||
386 | 32 | 33 | ||
387 | 33 | return super(ImageManager, self).create(**keyw) | 34 | return super(ImageManager, self).create(**keyw) |
388 | 34 | 35 | ||
390 | 35 | def create_and_save_image(self, user, image, content_type, object_id, ip): | 36 | def create_and_save_image(self, user, image, content_type, object_id): |
391 | 36 | # Use Django's get_valid_name() to get a safe filename | 37 | # Use Django's get_valid_name() to get a safe filename |
392 | 37 | storage = FileSystemStorage() | 38 | storage = FileSystemStorage() |
393 | 38 | safe_filename = storage.get_valid_name(image.name) | 39 | safe_filename = storage.get_valid_name(image.name) |
394 | 39 | im = self.create(content_type=content_type, object_id=object_id, | 40 | im = self.create(content_type=content_type, object_id=object_id, |
396 | 40 | user=user, revision=1, name=image.name, editor_ip=ip) | 41 | user=user, revision=1, name=image.name) |
397 | 41 | path = '%swlimages/%s' % (MEDIA_ROOT, safe_filename) | 42 | path = '%swlimages/%s' % (MEDIA_ROOT, safe_filename) |
398 | 42 | 43 | ||
399 | 43 | destination = open(path, 'wb') | 44 | destination = open(path, 'wb') |
400 | @@ -69,8 +70,6 @@ | |||
401 | 69 | 70 | ||
402 | 70 | # User Field | 71 | # User Field |
403 | 71 | user = models.ForeignKey(User) | 72 | user = models.ForeignKey(User) |
404 | 72 | editor_ip = models.GenericIPAddressField( | ||
405 | 73 | _('IP address'), null=True, blank=True) | ||
406 | 74 | 73 | ||
407 | 75 | # Date Fields | 74 | # Date Fields |
408 | 76 | date_submitted = models.DateTimeField( | 75 | date_submitted = models.DateTimeField( |
409 | 77 | 76 | ||
410 | === modified file 'wlimages/views.py' | |||
411 | --- wlimages/views.py 2018-04-03 05:18:03 +0000 | |||
412 | +++ wlimages/views.py 2018-10-03 20:25:29 +0000 | |||
413 | @@ -4,7 +4,6 @@ | |||
414 | 4 | from django.shortcuts import get_object_or_404, render | 4 | from django.shortcuts import get_object_or_404, render |
415 | 5 | 5 | ||
416 | 6 | from models import Image | 6 | from models import Image |
417 | 7 | from wl_utils import get_real_ip | ||
418 | 8 | from forms import UploadImageForm | 7 | from forms import UploadImageForm |
419 | 9 | 8 | ||
420 | 10 | 9 | ||
421 | @@ -31,7 +30,7 @@ | |||
422 | 31 | form = UploadImageForm(request.POST, request.FILES) | 30 | form = UploadImageForm(request.POST, request.FILES) |
423 | 32 | if form.is_valid(): # All validation rules pass | 31 | if form.is_valid(): # All validation rules pass |
424 | 33 | Image.objects.create_and_save_image(user=request.user, image=request.FILES['imagename'], | 32 | Image.objects.create_and_save_image(user=request.user, image=request.FILES['imagename'], |
426 | 34 | content_type=ContentType.objects.get(pk=content_type), object_id=object_id, ip=get_real_ip(request)) | 33 | content_type=ContentType.objects.get(pk=content_type), object_id=object_id) |
427 | 35 | return HttpResponseRedirect(next) # Redirect after POST | 34 | return HttpResponseRedirect(next) # Redirect after POST |
428 | 36 | else: | 35 | else: |
429 | 37 | form = UploadImageForm() # An unbound form | 36 | form = UploadImageForm() # An unbound form |
2 comments that might or might not need attention.