Просмотр исходного кода

Merge pull request #587 from NotKit/upgrade-deps

Upgrade Misago dependencies and support Django 1.9
Rafał Pitoń 9 лет назад
Родитель
Сommit
3f520b3bf6

+ 1 - 1
misago/core/fileserver.py

@@ -41,7 +41,7 @@ def rewrite_file_path(file_path):
 
 
 def make_stream_response(file_path, content_type, file_size, attachment=None):
-    response = StreamingHttpResponse(open(file_path, 'r'))
+    response = StreamingHttpResponse(open(file_path, 'rb'))
 
     response['Content-Type'] = content_type
     response['Content-Length'] = file_size

+ 2 - 17
misago/core/forms.py

@@ -97,24 +97,9 @@ class IsoDateTimeField(DateTimeField):
 """
 Forms
 """
-class AutoStripWhitespacesMixin(object):
-    autostrip_exclude = []
-
-    def full_clean(self):
-        self.data = self.data.copy()
-        for name, field in self.fields.iteritems():
-            if (field.__class__ in TEXT_BASED_FIELDS and
-                    not name in self.autostrip_exclude):
-                try:
-                    self.data[name] = (self.data[name] or '').strip()
-                except KeyError:
-                    pass
-        return super(AutoStripWhitespacesMixin, self).full_clean()
-
-
-class Form(AutoStripWhitespacesMixin, BaseForm):
+class Form(BaseForm):
     pass
 
 
-class ModelForm(AutoStripWhitespacesMixin, BaseModelForm):
+class ModelForm(BaseModelForm):
     pass

+ 1 - 1
misago/core/management/commands/misagodbrelations.py

@@ -36,7 +36,7 @@ class Command(BaseCommand):
                             self.stdout.write(field_pattern % (
                                 field.name,
                                 field.__class__.__name__,
-                                field.related.parent_model.__name__,
+                                field.related.model.__name__,
                                 field.rel.on_delete.__name__,
                             ))
 

+ 2 - 4
misago/core/pgutils.py

@@ -27,8 +27,7 @@ DROP INDEX %(index_name)s
 
     def database_forwards(self, app_label, schema_editor,
                           from_state, to_state):
-        apps = from_state.render()
-        model = apps.get_model(app_label, self.model)
+        model = from_state.apps.get_model(app_label, self.model)
 
         statement = self.CREATE_SQL % {
             'index_name': self.index_name,
@@ -89,8 +88,7 @@ DROP INDEX %(index_name)s
 
     def database_forwards(self, app_label, schema_editor,
                           from_state, to_state):
-        apps = from_state.render()
-        model = apps.get_model(app_label, self.model)
+        model = from_state.apps.get_model(app_label, self.model)
 
         statement = self.CREATE_SQL % {
             'index_name': self.index_name,

+ 1 - 1
misago/core/shortcuts.py

@@ -37,7 +37,7 @@ def pagination_dict(page, include_page_range=True):
     }
 
     if include_page_range:
-        pagination['page_range'] = page.paginator.page_range
+        pagination['page_range'] = list(page.paginator.page_range)
 
     if page.has_previous():
         pagination['first'] = 1

+ 1 - 2
misago/core/tests/test_forms.py

@@ -4,8 +4,7 @@ from misago.core import forms
 
 class MockForm(forms.Form):
     stripme = forms.CharField(required=False)
-    autostrip_exclude = ['dontstripme']
-    dontstripme = forms.CharField(required=False)
+    dontstripme = forms.CharField(required=False, strip=False)
 
 
 class MisagoFormsTests(TestCase):

+ 1 - 1
misago/core/tests/test_misagorequirements.py

@@ -13,4 +13,4 @@ class MisagoRequirementsTests(TestCase):
         command.execute(stdout=out)
         command_output = out.getvalue()
 
-        self.assertIn("django==", command_output)
+        self.assertIn("django", command_output)

+ 2 - 2
misago/core/tests/test_shortcuts.py

@@ -30,7 +30,7 @@ class PaginateTests(TestCase):
         """Explicit page number results in redirect"""
         response = self.client.get(
             reverse('test-pagination', kwargs={'page': 1}))
-        valid_url = "http://testserver/forum/test-pagination/"
+        valid_url = "/forum/test-pagination/"
         self.assertEqual(response['Location'], valid_url)
 
 
@@ -52,7 +52,7 @@ class ValidateSlugTests(TestCase):
             'pk': 1,
         }))
 
-        valid_url = "http://testserver/forum/test-valid-slug/eric-the-fish-1/"
+        valid_url = "/forum/test-valid-slug/eric-the-fish-1/"
         self.assertEqual(response['Location'], valid_url)
 
 

+ 14 - 13
misago/project_template/requirements.txt

@@ -1,16 +1,17 @@
-django==1.7.6
-djangorestframework==3.3.2
-beautifulsoup4==4.3.2
-bleach==1.4.1
-django-debug-toolbar==1.3.2
-django-crispy-forms==1.4.0
-django-htmlmin==0.7
-django-mptt==0.7.4
-fake-factory==0.4.2
-markdown==2.4.1
-path.py==7.0
-pillow==2.7.0
-psycopg2==2.5.4
+django~=1.9.6
+djangorestframework==3.3.3
+beautifulsoup4==4.4.1
+bleach==1.4.3
+django-debug-toolbar==1.4
+django-crispy-forms==1.6.0
+django-htmlmin==0.9.1
+django-mptt==0.8.4
+fake-factory~=0.5.7
+html5lib<0.99999999,>=0.999
+markdown==2.6.6
+path.py==8.2.1
+pillow==3.2.0
+psycopg2==2.6.1
 pytz
 requests<3
 unidecode

+ 1 - 1
misago/users/models/rank.py

@@ -26,7 +26,7 @@ class Rank(models.Model):
     slug = models.CharField(unique=True, max_length=255)
     description = models.TextField(null=True, blank=True)
     title = models.CharField(max_length=255, null=True, blank=True)
-    roles = models.ManyToManyField('misago_acl.Role', null=True, blank=True)
+    roles = models.ManyToManyField('misago_acl.Role', blank=True)
     css_class = models.CharField(max_length=255, null=True, blank=True)
     is_default = models.BooleanField(default=False)
     is_tab = models.BooleanField(default=False)

+ 2 - 2
misago/users/tests/test_auth_views.py

@@ -28,7 +28,7 @@ class AuthViewsTests(TestCase):
         })
 
         self.assertEqual(response.status_code, 302)
-        self.assertEqual(response['location'], 'http://testserver/redirect/')
+        self.assertEqual(response['location'], '/redirect/')
 
         # invalid redirect (redirects to other site)
         response = self.client.post(reverse('misago:login'), data={
@@ -36,7 +36,7 @@ class AuthViewsTests(TestCase):
         })
 
         self.assertEqual(response.status_code, 302)
-        self.assertEqual(response['location'], 'http://testserver/')
+        self.assertEqual(response['location'], '/')
 
     def test_logout_view(self):
         """logout view logs user out on post"""