Skip to content

Commit

Permalink
Merge pull request #406 from claudep/master
Browse files Browse the repository at this point in the history
Replaced/removed some old stuff
  • Loading branch information
etianen committed May 27, 2015
2 parents 4508083 + e59ba80 commit 1125b8c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
28 changes: 18 additions & 10 deletions src/reversion/management/commands/createinitialrevisions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
from __future__ import unicode_literals, print_function
from __future__ import unicode_literals

from optparse import make_option
try:
from collections import OrderedDict
except ImportError: # For Python 2.6
from django.utils.datastructures import SortedDict as OrderedDict

try:
from django.apps.apps import get_app, get_apps, get_model, get_models
except ImportError: # For Django < 1.7
from django.db.models import get_app, get_apps, get_model, get_models

from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import BaseCommand
from django.core.management.base import CommandError
from django.contrib.contenttypes.models import ContentType
from django.db import models, reset_queries
from django.db import reset_queries
from django.utils.importlib import import_module
from django.utils.datastructures import SortedDict
from django.utils.encoding import force_text

from reversion import default_revision_manager
Expand Down Expand Up @@ -46,25 +54,25 @@ def handle(self, *app_labels, **options):
database = options.get('database')

verbosity = int(options.get("verbosity", 1))
app_list = SortedDict()
app_list = OrderedDict()
# if no apps given, use all installed.
if len(app_labels) == 0:
for app in models.get_apps ():
for app in get_apps():
if not app in app_list:
app_list[app] = []
for model_class in models.get_models(app):
for model_class in get_models(app):
if not model_class in app_list[app]:
app_list[app].append(model_class)
else:
for label in app_labels:
try:
app_label, model_label = label.split(".")
try:
app = models.get_app(app_label)
app = get_app(app_label)
except ImproperlyConfigured:
raise CommandError("Unknown application: %s" % app_label)

model_class = models.get_model(app_label, model_label)
model_class = get_model(app_label, model_label)
if model_class is None:
raise CommandError("Unknown model: %s.%s" % (app_label, model_label))
if app in app_list:
Expand All @@ -76,10 +84,10 @@ def handle(self, *app_labels, **options):
# This is just an app - no model qualifier.
app_label = label
try:
app = models.get_app(app_label)
app = get_app(app_label)
if not app in app_list:
app_list[app] = []
for model_class in models.get_models(app):
for model_class in get_models(app):
if not model_class in app_list[app]:
app_list[app].append(model_class)
except ImproperlyConfigured:
Expand Down
2 changes: 1 addition & 1 deletion src/reversion/management/commands/deleterevisions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import unicode_literals, print_function
from __future__ import unicode_literals

import datetime, operator, sys
from optparse import make_option
Expand Down
7 changes: 6 additions & 1 deletion src/reversion/revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@
from weakref import WeakValueDictionary
import copy

try:
from django.apps.apps import get_model
except ImportError: # For Django < 1.7
from django.db.models import get_model

from django.contrib.contenttypes.models import ContentType
from django.core import serializers
from django.core.exceptions import ObjectDoesNotExist
from django.core.signals import request_finished
from django.db import models, connection, transaction
from django.db.models import Q, Max, get_model
from django.db.models import Q, Max
from django.db.models.query import QuerySet
from django.db.models.signals import post_save
from django.utils.encoding import force_text
Expand Down
1 change: 0 additions & 1 deletion src/reversion/templates/reversion/recover_form.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends "reversion/revision_form.html" %}
{% load url from future %}
{% load i18n %}


Expand Down
1 change: 0 additions & 1 deletion src/reversion/templates/reversion/recover_list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends "admin/base_site.html" %}
{% load url from future %}
{% load i18n l10n %}


Expand Down
1 change: 0 additions & 1 deletion src/reversion/templates/reversion/revision_form.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends "admin/change_form.html" %}
{% load url from future %}
{% load i18n %}


Expand Down

0 comments on commit 1125b8c

Please sign in to comment.