Just removing old cruft.
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Fri, 27 Mar 2015 09:13:09 +0000 (10:13 +0100)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Fri, 27 Mar 2015 09:13:09 +0000 (10:13 +0100)
17 files changed:
apps/apiclient/__init__.py
apps/catalogue/ebook_utils.py
apps/catalogue/management/__init__.py
apps/catalogue/management/commands/assign_from_redmine.py
apps/catalogue/management/commands/import_wl.py
apps/catalogue/management/commands/merge_books.py
apps/catalogue/managers.py
apps/catalogue/models/book.py
apps/catalogue/views.py
apps/cover/views.py
apps/dvcs/models.py
apps/toolbar/admin.py
apps/toolbar/management/commands/fixbuttons.py
apps/wiki/helpers.py
apps/wiki/templates/admin/wiki/theme/change_list.html
apps/wiki_img/views.py
redakcja/settings/common.py

index 33d2008..38ce26e 100644 (file)
@@ -1,9 +1,8 @@
 import urllib
 
 import urllib
 
-from django.utils import simplejson
+import json
 import oauth2
 
 import oauth2
 
-from apiclient.models import OAuthConnection
 from apiclient.settings import WL_CONSUMER_KEY, WL_CONSUMER_SECRET, WL_API_URL
 
 
 from apiclient.settings import WL_CONSUMER_KEY, WL_CONSUMER_SECRET, WL_API_URL
 
 
@@ -22,13 +21,14 @@ class NotAuthorizedError(BaseException):
 
 
 def api_call(user, path, data=None):
 
 
 def api_call(user, path, data=None):
+    from .models import OAuthConnection
     conn = OAuthConnection.get(user)
     if not conn.access:
         raise NotAuthorizedError("No WL authorization for user %s." % user)
     token = oauth2.Token(conn.token, conn.token_secret)
     client = oauth2.Client(wl_consumer, token)
     if data is not None:
     conn = OAuthConnection.get(user)
     if not conn.access:
         raise NotAuthorizedError("No WL authorization for user %s." % user)
     token = oauth2.Token(conn.token, conn.token_secret)
     client = oauth2.Client(wl_consumer, token)
     if data is not None:
-        data = simplejson.dumps(data)
+        data = json.dumps(data)
         data = urllib.urlencode({"data": data})
         resp, content = client.request(
                 "%s%s" % (WL_API_URL, path),
         data = urllib.urlencode({"data": data})
         resp, content = client.request(
                 "%s%s" % (WL_API_URL, path),
@@ -40,7 +40,7 @@ def api_call(user, path, data=None):
     status = resp['status']
 
     if status == '200':
     status = resp['status']
 
     if status == '200':
-        return simplejson.loads(content)
+        return json.loads(content)
     elif status.startswith('2'):
         return
     elif status == '401':
     elif status.startswith('2'):
         return
     elif status == '401':
index d9c9922..dae2e76 100644 (file)
@@ -24,7 +24,7 @@ def serve_file(file_path, name, mime_type):
             yield chunk
             chunk = f.read(size)
 
             yield chunk
             chunk = f.read(size)
 
-    response = HttpResponse(mimetype=mime_type)
+    response = HttpResponse(content_type=mime_type)
     response['Content-Disposition'] = 'attachment; filename=%s' % name
     with open(file_path) as f:
         for chunk in read_chunks(f):
     response['Content-Disposition'] = 'attachment; filename=%s' % name
     with open(file_path) as f:
         for chunk in read_chunks(f):
index f7731d7..bc3d6c0 100644 (file)
@@ -100,9 +100,7 @@ class XmlUpdater(object):
             books = Book.objects.all()
 
         # Start transaction management.
             books = Book.objects.all()
 
         # Start transaction management.
-        transaction.commit_unless_managed()
         transaction.enter_transaction_management()
         transaction.enter_transaction_management()
-        transaction.managed(True)
 
         for book in books:
             self.counters['All books'] += 1
 
         for book in books:
             self.counters['All books'] += 1
index 31bdc14..491fd83 100644 (file)
@@ -47,9 +47,7 @@ class Command(BaseCommand):
             redmine_csv = REDMINE_CSV
 
         # Start transaction management.
             redmine_csv = REDMINE_CSV
 
         # Start transaction management.
-        transaction.commit_unless_managed()
         transaction.enter_transaction_management()
         transaction.enter_transaction_management()
-        transaction.managed(True)
 
         redakcja_link = re.compile(re.escape(redakcja) + r'([-_.:?&%/a-zA-Z0-9]*)')
 
 
         redakcja_link = re.compile(re.escape(redakcja) + r'([-_.:?&%/a-zA-Z0-9]*)')
 
index 5f60388..7eee897 100644 (file)
@@ -31,9 +31,7 @@ class Command(BaseCommand):
         verbose = options.get('verbose')
 
         # Start transaction management.
         verbose = options.get('verbose')
 
         # Start transaction management.
-        transaction.commit_unless_managed()
         transaction.enter_transaction_management()
         transaction.enter_transaction_management()
-        transaction.managed(True)
 
         if verbose:
             print 'Reading currently managed files (skipping hidden ones).'
 
         if verbose:
             print 'Reading currently managed files (skipping hidden ones).'
index 5499d3d..82bd622 100644 (file)
@@ -126,9 +126,7 @@ class Command(BaseCommand):
             return
 
         # Start transaction management.
             return
 
         # Start transaction management.
-        transaction.commit_unless_managed()
         transaction.enter_transaction_management()
         transaction.enter_transaction_management()
-        transaction.managed(True)
 
         books = [Book.objects.get(slug=slug) for slug in slugs]
         common_slug = common_prefix(slugs)
 
         books = [Book.objects.get(slug=slug) for slug in slugs]
         common_slug = common_prefix(slugs)
index 4f804b8..a131ce9 100644 (file)
@@ -1,5 +1,5 @@
 from django.db import models
 
 class VisibleManager(models.Manager):
 from django.db import models
 
 class VisibleManager(models.Manager):
-    def get_query_set(self):
-        return super(VisibleManager, self).get_query_set().exclude(_hidden=True)
+    def get_queryset(self):
+        return super(VisibleManager, self).get_queryset().exclude(_hidden=True)
index e320af7..f109474 100755 (executable)
@@ -94,7 +94,7 @@ class Book(models.Model):
         return self.public or request.user.is_authenticated()
 
     @classmethod
         return self.public or request.user.is_authenticated()
 
     @classmethod
-    @transaction.commit_on_success
+    @transaction.atomic
     def create(cls, creator, text, *args, **kwargs):
         b = cls.objects.create(*args, **kwargs)
         b.chunk_set.all().update(creator=creator)
     def create(cls, creator, text, *args, **kwargs):
         b = cls.objects.create(*args, **kwargs)
         b.chunk_set.all().update(creator=creator)
@@ -106,7 +106,7 @@ class Book(models.Model):
         return self.chunk_set.reverse()[0].split(*args, **kwargs)
 
     @classmethod
         return self.chunk_set.reverse()[0].split(*args, **kwargs)
 
     @classmethod
-    @transaction.commit_on_success
+    @transaction.atomic
     def import_xml_text(cls, text=u'', previous_book=None,
                 commit_args=None, **kwargs):
         """Imports a book from XML, splitting it into chunks as necessary."""
     def import_xml_text(cls, text=u'', previous_book=None,
                 commit_args=None, **kwargs):
         """Imports a book from XML, splitting it into chunks as necessary."""
@@ -153,7 +153,7 @@ class Book(models.Model):
             i += 1
         return new_slug
 
             i += 1
         return new_slug
 
-    @transaction.commit_on_success
+    @transaction.atomic
     def append(self, other, slugs=None, titles=None):
         """Add all chunks of another book to self."""
         assert self != other
     def append(self, other, slugs=None, titles=None):
         """Add all chunks of another book to self."""
         assert self != other
@@ -213,7 +213,7 @@ class Book(models.Model):
         other.delete()
 
 
         other.delete()
 
 
-    @transaction.commit_on_success
+    @transaction.atomic
     def prepend_history(self, other):
         """Prepend history from all the other book's chunks to own."""
         assert self != other
     def prepend_history(self, other):
         """Prepend history from all the other book's chunks to own."""
         assert self != other
index 8a96dc6..af2efe2 100644 (file)
@@ -210,7 +210,7 @@ def book_xml(request, slug):
         return HttpResponseForbidden("Not authorized.")
     xml = book.materialize()
 
         return HttpResponseForbidden("Not authorized.")
     xml = book.materialize()
 
-    response = http.HttpResponse(xml, content_type='application/xml', mimetype='application/wl+xml')
+    response = http.HttpResponse(xml, content_type='application/xml')
     response['Content-Disposition'] = 'attachment; filename=%s.xml' % slug
     return response
 
     response['Content-Disposition'] = 'attachment; filename=%s.xml' % slug
     return response
 
@@ -223,7 +223,7 @@ def book_txt(request, slug):
 
     doc = book.wldocument()
     text = doc.as_text().get_string()
 
     doc = book.wldocument()
     text = doc.as_text().get_string()
-    response = http.HttpResponse(text, content_type='text/plain', mimetype='text/plain')
+    response = http.HttpResponse(text, content_type='text/plain')
     response['Content-Disposition'] = 'attachment; filename=%s.txt' % slug
     return response
 
     response['Content-Disposition'] = 'attachment; filename=%s.txt' % slug
     return response
 
@@ -238,7 +238,7 @@ def book_html(request, slug):
     html = doc.as_html()
 
     html = html.get_string() if html is not None else ''
     html = doc.as_html()
 
     html = html.get_string() if html is not None else ''
-    # response = http.HttpResponse(html, content_type='text/html', mimetype='text/html')
+    # response = http.HttpResponse(html, content_type='text/html')
     # return response
     # book_themes = {}
     # for fragment in book.fragments.all().iterator():
     # return response
     # book_themes = {}
     # for fragment in book.fragments.all().iterator():
@@ -275,7 +275,7 @@ def book_epub(request, slug):
     doc = book.wldocument()
     # TODO: error handling
     epub = doc.as_epub().get_string()
     doc = book.wldocument()
     # TODO: error handling
     epub = doc.as_epub().get_string()
-    response = HttpResponse(mimetype='application/epub+zip')
+    response = HttpResponse(content_type='application/epub+zip')
     response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.epub'
     response.write(epub)
     return response
     response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.epub'
     response.write(epub)
     return response
@@ -426,7 +426,7 @@ def chunk_edit(request, slug, chunk):
     })
 
 
     })
 
 
-@transaction.commit_on_success
+@transaction.atomic
 @login_required
 @require_POST
 def chunk_mass_edit(request):
 @login_required
 @require_POST
 def chunk_mass_edit(request):
@@ -469,7 +469,7 @@ def chunk_mass_edit(request):
     return HttpResponse("", content_type="text/plain")
 
 
     return HttpResponse("", content_type="text/plain")
 
 
-@transaction.commit_on_success
+@transaction.atomic
 @login_required
 @require_POST
 def image_mass_edit(request):
 @login_required
 @require_POST
 def image_mass_edit(request):
index 6b3344b..4a6e575 100644 (file)
@@ -46,7 +46,7 @@ def preview(request, book, chunk=None, rev=None):
     except:
         return HttpResponseRedirect(os.path.join(settings.STATIC_URL, "img/sample_cover.png"))
     cover = DefaultEbookCover(info)
     except:
         return HttpResponseRedirect(os.path.join(settings.STATIC_URL, "img/sample_cover.png"))
     cover = DefaultEbookCover(info)
-    response = HttpResponse(mimetype=cover.mime_type())
+    response = HttpResponse(content_type=cover.mime_type())
     image = cover.image().resize(PREVIEW_SIZE, Image.ANTIALIAS)
     image.save(response, cover.format)
     return response
     image = cover.image().resize(PREVIEW_SIZE, Image.ANTIALIAS)
     image.save(response, cover.format)
     return response
index ec64794..e82ad19 100644 (file)
@@ -329,7 +329,7 @@ class Document(models.Model):
         else:
             return None
 
         else:
             return None
 
-    @transaction.commit_on_success
+    @transaction.atomic
     def prepend_history(self, other):
         """Takes over the the other document's history and prepends to own."""
 
     def prepend_history(self, other):
         """Takes over the the other document's history and prepends to own."""
 
index 283ab78..654480c 100644 (file)
@@ -1,7 +1,7 @@
 from django.contrib import admin
 from django.utils.translation import ugettext_lazy as _
 from django import forms
 from django.contrib import admin
 from django.utils.translation import ugettext_lazy as _
 from django import forms
-from django.utils import simplejson as json
+import json
 
 from toolbar import models
 
 
 from toolbar import models
 
@@ -9,6 +9,7 @@ from toolbar import models
 class ButtonAdminForm(forms.ModelForm):
     class Meta:
         model = models.Button
 class ButtonAdminForm(forms.ModelForm):
     class Meta:
         model = models.Button
+        exclude = []
 
     def clean_params(self):
         value = self.cleaned_data['params']
 
     def clean_params(self):
         value = self.cleaned_data['params']
index ea797fc..de48ced 100644 (file)
@@ -7,7 +7,7 @@
 
 from django.core.management.base import NoArgsCommand
 from toolbar.models import Button, ButtonGroup
 
 from django.core.management.base import NoArgsCommand
 from toolbar.models import Button, ButtonGroup
-from django.utils import simplejson as json
+import json
 import re
 
 
 import re
 
 
index dace3d0..877a9d0 100644 (file)
@@ -2,7 +2,7 @@ from datetime import datetime
 from functools import wraps
 
 from django import http
 from functools import wraps
 
 from django import http
-from django.utils import simplejson as json
+import json
 from django.utils.functional import Promise
 
 
 from django.utils.functional import Promise
 
 
@@ -22,11 +22,11 @@ class ExtendedEncoder(json.JSONEncoder):
 class JSONResponse(http.HttpResponse):
 
     def __init__(self, data={}, **kwargs):
 class JSONResponse(http.HttpResponse):
 
     def __init__(self, data={}, **kwargs):
-        # get rid of mimetype
-        kwargs.pop('mimetype', None)
+        # get rid of content_type
+        kwargs.pop('content_type', None)
 
         data = json.dumps(data, cls=ExtendedEncoder)
 
         data = json.dumps(data, cls=ExtendedEncoder)
-        super(JSONResponse, self).__init__(data, mimetype="application/json", **kwargs)
+        super(JSONResponse, self).__init__(data, content_type="application/json", **kwargs)
 
 
 # return errors
 
 
 # return errors
@@ -45,7 +45,7 @@ def ajax_login_required(view):
     @wraps(view)
     def authenticated_view(request, *args, **kwargs):
         if not request.user.is_authenticated():
     @wraps(view)
     def authenticated_view(request, *args, **kwargs):
         if not request.user.is_authenticated():
-            return http.HttpResponse("Login required.", status=401, mimetype="text/plain")
+            return http.HttpResponse("Login required.", status=401, content_type="text/plain")
         return view(request, *args, **kwargs)
     return authenticated_view
 
         return view(request, *args, **kwargs)
     return authenticated_view
 
@@ -55,7 +55,7 @@ def ajax_require_permission(permission):
         @wraps(view)
         def authorized_view(request, *args, **kwargs):
             if not request.user.has_perm(permission):
         @wraps(view)
         def authorized_view(request, *args, **kwargs):
             if not request.user.has_perm(permission):
-                return http.HttpResponse("Access Forbidden.", status=403, mimetype="text/plain")
+                return http.HttpResponse("Access Forbidden.", status=403, content_type="text/plain")
             return view(request, *args, **kwargs)
         return authorized_view
     return decorator
             return view(request, *args, **kwargs)
         return authorized_view
     return decorator
index 919b0b9..3e5d2ea 100755 (executable)
@@ -21,7 +21,7 @@
 
 <a id="redmine-table-switch">↓ {% trans "Table for Redmine wiki" %} ↓</a>
 <div id="redmine-table" style="display:none; padding:1em; border: 1px solid #aaa;">
 
 <a id="redmine-table-switch">↓ {% trans "Table for Redmine wiki" %} ↓</a>
 <div id="redmine-table" style="display:none; padding:1em; border: 1px solid #aaa;">
-    |{% for theme in cl.get_query_set %}[[{{ theme }}]]|{% if forloop.counter|divisibleby:7 %}<br/>
+    |{% for theme in cl.get_queryset %}[[{{ theme }}]]|{% if forloop.counter|divisibleby:7 %}<br/>
         |{% endif %}{% endfor %}
 </div>
 
         |{% endif %}{% endfor %}
 </div>
 
index 08a0a03..2b8dd67 100644 (file)
@@ -7,7 +7,7 @@ from django.core.urlresolvers import reverse
 from wiki.helpers import (JSONResponse, JSONFormInvalid, JSONServerError,
                 ajax_require_permission)
 
 from wiki.helpers import (JSONResponse, JSONFormInvalid, JSONServerError,
                 ajax_require_permission)
 
-from django import http
+from django.http import Http404, HttpResponse, HttpResponseForbidden
 from django.shortcuts import get_object_or_404, render
 from django.views.decorators.http import require_GET, require_POST
 from django.conf import settings
 from django.shortcuts import get_object_or_404, render
 from django.views.decorators.http import require_GET, require_POST
 from django.conf import settings
@@ -188,7 +188,7 @@ def diff(request, object_id):
         docA = ""
     docB = doc.at_revision(revB).materialize()
 
         docA = ""
     docB = doc.at_revision(revB).materialize()
 
-    return http.HttpResponse(nice_diff.html_diff_table(docA.splitlines(),
+    return HttpResponse(nice_diff.html_diff_table(docA.splitlines(),
                                          docB.splitlines(), context=3))
 
 
                                          docB.splitlines(), context=3))
 
 
index 0c1a009..5146dcd 100644 (file)
@@ -79,7 +79,7 @@ MIDDLEWARE_CLASSES = (
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django_cas.middleware.CASMiddleware',
 
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django_cas.middleware.CASMiddleware',
 
-    'django.middleware.doc.XViewMiddleware',
+    'django.contrib.admindocs.middleware.XViewMiddleware',
     'pagination.middleware.PaginationMiddleware',
     'maintenancemode.middleware.MaintenanceModeMiddleware',
 )
     'pagination.middleware.PaginationMiddleware',
     'maintenancemode.middleware.MaintenanceModeMiddleware',
 )