Skip to content
Browse files

usr

  • Loading branch information...
1 parent 495739e commit afcfa2c5217b14980f09eac78a4f8b4bdc69f39d @miclovich miclovich committed Apr 2, 2012
Showing with 6 additions and 4,760 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 edtrac_project/django_reversion
  3. +0 −10 edtrac_project/django_reversion/.gitignore
  4. +0 −74 edtrac_project/django_reversion/reversion/__init__.py
  5. +0 −443 edtrac_project/django_reversion/reversion/admin.py
  6. +0 −82 edtrac_project/django_reversion/reversion/helpers.py
  7. BIN edtrac_project/django_reversion/reversion/locale/cs/LC_MESSAGES/django.mo
  8. +0 −128 edtrac_project/django_reversion/reversion/locale/cs/LC_MESSAGES/django.po
  9. BIN edtrac_project/django_reversion/reversion/locale/de/LC_MESSAGES/django.mo
  10. +0 −129 edtrac_project/django_reversion/reversion/locale/de/LC_MESSAGES/django.po
  11. BIN edtrac_project/django_reversion/reversion/locale/fr/LC_MESSAGES/django.mo
  12. +0 −127 edtrac_project/django_reversion/reversion/locale/fr/LC_MESSAGES/django.po
  13. BIN edtrac_project/django_reversion/reversion/locale/he/LC_MESSAGES/django.mo
  14. +0 −123 edtrac_project/django_reversion/reversion/locale/he/LC_MESSAGES/django.po
  15. BIN edtrac_project/django_reversion/reversion/locale/it/LC_MESSAGES/django.mo
  16. +0 −113 edtrac_project/django_reversion/reversion/locale/it/LC_MESSAGES/django.po
  17. BIN edtrac_project/django_reversion/reversion/locale/nb/LC_MESSAGES/django.mo
  18. +0 −116 edtrac_project/django_reversion/reversion/locale/nb/LC_MESSAGES/django.po
  19. BIN edtrac_project/django_reversion/reversion/locale/pl/LC_MESSAGES/django.mo
  20. +0 −124 edtrac_project/django_reversion/reversion/locale/pl/LC_MESSAGES/django.po
  21. BIN edtrac_project/django_reversion/reversion/locale/ru/LC_MESSAGES/django.mo
  22. +0 −118 edtrac_project/django_reversion/reversion/locale/ru/LC_MESSAGES/django.po
  23. +0 −1 edtrac_project/django_reversion/reversion/management/__init__.py
  24. 0 edtrac_project/django_reversion/reversion/management/commands/__init__.py
  25. +0 −109 edtrac_project/django_reversion/reversion/management/commands/createinitialrevisions.py
  26. +0 −195 edtrac_project/django_reversion/reversion/management/commands/deleterevisions.py
  27. +0 −34 edtrac_project/django_reversion/reversion/middleware.py
  28. +0 −97 edtrac_project/django_reversion/reversion/migrations/0001_initial.py
  29. +0 −79 edtrac_project/django_reversion/reversion/migrations/0002_auto__add_field_version_type.py
  30. +0 −79 edtrac_project/django_reversion/reversion/migrations/0003_auto__add_field_version_object_id_int.py
  31. +0 −89 edtrac_project/django_reversion/reversion/migrations/0004_populate_object_id_int.py
  32. +0 −80 edtrac_project/django_reversion/reversion/migrations/0005_auto__add_field_revision_manager_slug.py
  33. 0 edtrac_project/django_reversion/reversion/migrations/__init__.py
  34. +0 −298 edtrac_project/django_reversion/reversion/models.py
  35. +0 −599 edtrac_project/django_reversion/reversion/revisions.py
  36. +0 −10 edtrac_project/django_reversion/reversion/templates/reversion/change_list.html
  37. +0 −41 edtrac_project/django_reversion/reversion/templates/reversion/object_history.html
  38. +0 −18 edtrac_project/django_reversion/reversion/templates/reversion/recover_form.html
  39. +0 −42 edtrac_project/django_reversion/reversion/templates/reversion/recover_list.html
  40. +0 −27 edtrac_project/django_reversion/reversion/templates/reversion/revision_form.html
  41. +0 −769 edtrac_project/django_reversion/reversion/tests.py
  42. +0 −604 edtrac_project/django_reversion/reversion/tests_deprecated.py
  43. +1 −1 edtrac_project/rapidsms_edtrac
  44. +1 −1 edtrac_project/settings.py
View
3 .gitmodules
@@ -43,3 +43,6 @@
[submodule "edtrac_project/monitor_src"]
path = edtrac_project/monitor_src
url = git://github.com/unicefuganda/monitor_src.git
+[submodule "edtrac_project/django_reversion"]
+ path = edtrac_project/django_reversion
+ url = https://github.com/etianen/django-reversion.git
1 edtrac_project/django_reversion
@@ -0,0 +1 @@
+Subproject commit a301d6650a432ae334cce5ec7aa8c41311629904
View
10 edtrac_project/django_reversion/.gitignore
@@ -1,10 +0,0 @@
-.DS_Store
-*.db
-.project
-.pydevproject
-.settings
-*.pyc
-*.pyo
-dist
-build
-MANIFEST
View
74 edtrac_project/django_reversion/reversion/__init__.py
@@ -1,74 +0,0 @@
-"""
-Transactional version control for Django models.
-
-Developed by Dave Hall.
-
-<http://www.etianen.com/>
-"""
-
-import django, warnings
-
-from reversion.revisions import default_revision_manager, revision_context_manager, VersionAdapter
-from reversion.admin import VersionAdmin
-
-
-VERSION = (1, 5, 1)
-
-SUPPORTED_DJANGO_VERSIONS = (
- (1, 3, 1),
- (1, 3, 0),
-)
-
-def check_django_version():
- """Checks the version of django being used, and issues a warning if incorrect."""
- if django.VERSION[:3] not in SUPPORTED_DJANGO_VERSIONS:
- format_version = lambda v: u".".join(unicode(n) for n in v)
- warnings.warn(
- (
- u"django-reversion %(reversion_version)s is intended for use with django %(supported_django_version)s. "
- u"You are running django %(django_version)s, so some features, such as admin integration, may not work. "
- u"Please see https://github.com/etianen/django-reversion/wiki/Compatible-Django-Versions"
- ) % {
- "reversion_version": format_version(VERSION),
- "supported_django_version": ' or '.join(format_version(v) for v in SUPPORTED_DJANGO_VERSIONS),
- "django_version": format_version(django.VERSION[:3]),
- }
- )
-
-check_django_version()
-
-
-# Legacy revision reference.
-revision = default_revision_manager # TODO: Deprecate eventually.
-
-
-# Easy registration methods.
-register = default_revision_manager.register
-is_registered = default_revision_manager.is_registered
-unregister = default_revision_manager.unregister
-get_adapter = default_revision_manager.get_adapter
-get_registered_models = default_revision_manager.get_registered_models
-
-
-# Context management.
-create_revision = revision_context_manager.create_revision
-
-
-# Revision meta data.
-get_db = revision_context_manager.get_db
-set_db = revision_context_manager.set_db
-get_user = revision_context_manager.get_user
-set_user = revision_context_manager.set_user
-get_comment = revision_context_manager.get_comment
-set_comment = revision_context_manager.set_comment
-add_meta = revision_context_manager.add_meta
-get_ignore_duplicates = revision_context_manager.get_ignore_duplicates
-set_ignore_duplicates = revision_context_manager.set_ignore_duplicates
-
-
-# Low level API.
-get_for_object_reference = default_revision_manager.get_for_object_reference
-get_for_object = default_revision_manager.get_for_object
-get_unique_for_object = default_revision_manager.get_unique_for_object
-get_for_date = default_revision_manager.get_for_date
-get_deleted = default_revision_manager.get_deleted
View
443 edtrac_project/django_reversion/reversion/admin.py
@@ -1,443 +0,0 @@
-"""Admin extensions for django-reversion."""
-
-from django import template
-from django.db import models, transaction, connection
-from django.conf.urls.defaults import patterns, url
-from django.contrib import admin
-from django.contrib.admin import helpers, options
-from django.contrib.admin.util import unquote, quote
-from django.contrib.contenttypes.generic import GenericInlineModelAdmin, GenericRelation
-from django.contrib.contenttypes.models import ContentType
-from django.core.urlresolvers import reverse
-from django.core.exceptions import ImproperlyConfigured
-from django.forms.formsets import all_valid
-from django.forms.models import model_to_dict
-from django.http import HttpResponseRedirect
-from django.shortcuts import get_object_or_404, render_to_response
-from django.utils.dateformat import format
-from django.utils.html import mark_safe
-from django.utils.text import capfirst
-from django.utils.translation import ugettext as _
-from django.utils.encoding import force_unicode
-
-from reversion.models import Revision, Version, has_int_pk
-from reversion.revisions import revision_context_manager, default_revision_manager, RegistrationError
-
-
-class VersionAdmin(admin.ModelAdmin):
-
- """Abstract admin class for handling version controlled models."""
-
- object_history_template = "reversion/object_history.html"
-
- change_list_template = "reversion/change_list.html"
-
- revision_form_template = None
-
- recover_list_template = None
-
- recover_form_template = None
-
- # The revision manager instance used to manage revisions.
- revision_manager = default_revision_manager
-
- # The serialization format to use when registering models with reversion.
- reversion_format = "json"
-
- # Whether to ignore duplicate revision data.
- ignore_duplicate_revisions = False
-
- # If True, then the default ordering of object_history and recover lists will be reversed.
- history_latest_first = False
-
- def _autoregister(self, model, follow=None):
- """Registers a model with reversion, if required."""
- if model._meta.proxy:
- raise RegistrationError("Proxy models cannot be used with django-reversion, register the parent class instead")
- if not self.revision_manager.is_registered(model):
- follow = follow or []
- for parent_cls, field in model._meta.parents.items():
- follow.append(field.name)
- self._autoregister(parent_cls)
- self.revision_manager.register(model, follow=follow, format=self.reversion_format)
-
- def __init__(self, *args, **kwargs):
- """Initializes the VersionAdmin"""
- super(VersionAdmin, self).__init__(*args, **kwargs)
- # Automatically register models if required.
- if not self.revision_manager.is_registered(self.model):
- inline_fields = []
- for inline in self.inlines:
- inline_model = inline.model
- self._autoregister(inline_model)
- if issubclass(inline, GenericInlineModelAdmin):
- ct_field = inline.ct_field
- ct_fk_field = inline.ct_fk_field
- for field in self.model._meta.many_to_many:
- if isinstance(field, GenericRelation) and field.rel.to == inline_model and field.object_id_field_name == ct_fk_field and field.content_type_field_name == ct_field:
- inline_fields.append(field.name)
- elif issubclass(inline, options.InlineModelAdmin):
- fk_name = inline.fk_name
- if not fk_name:
- for field in inline_model._meta.fields:
- if isinstance(field, (models.ForeignKey, models.OneToOneField)) and issubclass(self.model, field.rel.to):
- fk_name = field.name
- if not inline_model._meta.get_field(fk_name).rel.is_hidden():
- accessor = inline_model._meta.get_field(fk_name).related.get_accessor_name()
- inline_fields.append(accessor)
- self._autoregister(self.model, inline_fields)
-
- def _get_template_list(self, template_name):
- opts = self.model._meta
- return (
- "reversion/%s/%s/%s" % (opts.app_label, opts.object_name.lower(), template_name),
- "reversion/%s/%s" % (opts.app_label, template_name),
- "reversion/%s" % template_name,
- )
-
- def get_urls(self):
- """Returns the additional urls used by the Reversion admin."""
- urls = super(VersionAdmin, self).get_urls()
- admin_site = self.admin_site
- opts = self.model._meta
- info = opts.app_label, opts.module_name,
- reversion_urls = patterns("",
- url("^recover/$", admin_site.admin_view(self.recoverlist_view), name='%s_%s_recoverlist' % info),
- url("^recover/([^/]+)/$", admin_site.admin_view(self.recover_view), name='%s_%s_recover' % info),
- url("^([^/]+)/history/([^/]+)/$", admin_site.admin_view(self.revision_view), name='%s_%s_revision' % info),)
- return reversion_urls + urls
-
- def log_addition(self, request, object):
- """Sets the version meta information."""
- super(VersionAdmin, self).log_addition(request, object)
- revision_context_manager.set_user(request.user)
- revision_context_manager.set_comment(_(u"Initial version."))
- revision_context_manager.set_ignore_duplicates(self.ignore_duplicate_revisions)
-
- def log_change(self, request, object, message):
- """Sets the version meta information."""
- super(VersionAdmin, self).log_change(request, object, message)
- revision_context_manager.set_user(request.user)
- revision_context_manager.set_comment(message)
- revision_context_manager.set_ignore_duplicates(self.ignore_duplicate_revisions)
-
- def log_deletion(self, request, object, object_repr):
- """Sets the version meta information."""
- super(VersionAdmin, self).log_deletion(request, object, object_repr)
- revision_context_manager.set_user(request.user)
- revision_context_manager.set_comment(_(u"Deleted %(verbose_name)s.") % {"verbose_name": self.model._meta.verbose_name})
- revision_context_manager.set_ignore_duplicates(self.ignore_duplicate_revisions)
-
- def _order_version_queryset(self, queryset):
- """Applies the correct ordering to the given version queryset."""
- if self.history_latest_first:
- return queryset.order_by("-pk")
- return queryset.order_by("pk")
-
- def recoverlist_view(self, request, extra_context=None):
- """Displays a deleted model to allow recovery."""
- model = self.model
- opts = model._meta
- deleted = self._order_version_queryset(self.revision_manager.get_deleted(self.model))
- context = {
- "opts": opts,
- "app_label": opts.app_label,
- "module_name": capfirst(opts.verbose_name),
- "title": _("Recover deleted %(name)s") % {"name": force_unicode(opts.verbose_name_plural)},
- "deleted": deleted,
- "changelist_url": reverse("%s:%s_%s_changelist" % (self.admin_site.name, opts.app_label, opts.module_name)),
- }
- extra_context = extra_context or {}
- context.update(extra_context)
- return render_to_response(self.recover_list_template or self._get_template_list("recover_list.html"),
- context, template.RequestContext(request))
-
- def get_revision_form_data(self, request, obj, version):
- """
- Returns a dictionary of data to set in the admin form in order to revert
- to the given revision.
- """
- return version.field_dict
-
- def get_related_versions(self, obj, version, FormSet):
- """Retreives all the related Version objects for the given FormSet."""
- object_id = obj.pk
- # Get the fk name.
- try:
- fk_name = FormSet.fk.name
- except AttributeError:
- # This is a GenericInlineFormset, or similar.
- fk_name = FormSet.ct_fk_field.name
- # Look up the revision data.
- revision_versions = version.revision.version_set.all()
- related_versions = dict([(related_version.object_id, related_version)
- for related_version in revision_versions
- if ContentType.objects.get_for_id(related_version.content_type_id).model_class() == FormSet.model
- and unicode(related_version.field_dict[fk_name]) == unicode(object_id)])
- return related_versions
-
- def _hack_inline_formset_initial(self, FormSet, formset, obj, version, revert, recover):
- """Hacks the given formset to contain the correct initial data."""
- # Now we hack it to push in the data from the revision!
- initial = []
- related_versions = self.get_related_versions(obj, version, FormSet)
- formset.related_versions = related_versions
- for related_obj in formset.queryset:
- if unicode(related_obj.pk) in related_versions:
- initial.append(related_versions.pop(unicode(related_obj.pk)).field_dict)
- else:
- initial_data = model_to_dict(related_obj)
- initial_data["DELETE"] = True
- initial.append(initial_data)
- for related_version in related_versions.values():
- initial_row = related_version.field_dict
- pk_name = ContentType.objects.get_for_id(related_version.content_type_id).model_class()._meta.pk.name
- del initial_row[pk_name]
- initial.append(initial_row)
- # Reconstruct the forms with the new revision data.
- formset.initial = initial
- formset.forms = [formset._construct_form(n) for n in xrange(len(initial))]
- # Hack the formset to force a save of everything.
- for form in formset.forms:
- form.has_changed = lambda: True
- form._get_changed_data = lambda: [field.name for field in form.fields] # TODO: Scope this in a partial function.
- def total_form_count_hack(count):
- return lambda: count
- formset.total_form_count = total_form_count_hack(len(initial))
-
- def render_revision_form(self, request, obj, version, context, revert=False, recover=False):
- """Renders the object revision form."""
- model = self.model
- opts = model._meta
- object_id = obj.pk
- # Generate the model form.
- ModelForm = self.get_form(request, obj)
- formsets = []
- if request.method == "POST":
- # This section is copied directly from the model admin change view
- # method. Maybe one day there will be a hook for doing this better.
- form = ModelForm(request.POST, request.FILES, instance=obj, initial=self.get_revision_form_data(request, obj, version))
- if form.is_valid():
- form_validated = True
- new_object = self.save_form(request, form, change=True)
- # HACK: If the value of a file field is None, remove the file from the model.
- for field in new_object._meta.fields:
- if isinstance(field, models.FileField) and field.name in form.cleaned_data and form.cleaned_data[field.name] is None:
- setattr(new_object, field.name, None)
- else:
- form_validated = False
- new_object = obj
- prefixes = {}
- for FormSet, inline in zip(self.get_formsets(request, new_object),
- self.inline_instances):
- prefix = FormSet.get_default_prefix()
- prefixes[prefix] = prefixes.get(prefix, 0) + 1
- if prefixes[prefix] != 1:
- prefix = "%s-%s" % (prefix, prefixes[prefix])
- formset = FormSet(request.POST, request.FILES,
- instance=new_object, prefix=prefix,
- queryset=inline.queryset(request))
- self._hack_inline_formset_initial(FormSet, formset, obj, version, revert, recover)
- # Add this hacked formset to the form.
- formsets.append(formset)
- if all_valid(formsets) and form_validated:
- self.save_model(request, new_object, form, change=True)
- form.save_m2m()
- for formset in formsets:
- # HACK: If the value of a file field is None, remove the file from the model.
- related_objects = formset.save(commit=False)
- for related_obj, related_form in zip(related_objects, formset.saved_forms):
- for field in related_obj._meta.fields:
- if isinstance(field, models.FileField) and field.name in related_form.cleaned_data and related_form.cleaned_data[field.name] is None:
- setattr(related_obj, field.name, None)
- related_obj.save()
- formset.save_m2m()
- change_message = _(u"Reverted to previous version, saved on %(datetime)s") % {"datetime": format(version.revision.date_created, _('DATETIME_FORMAT'))}
- self.log_change(request, new_object, change_message)
- self.message_user(request, _(u'The %(model)s "%(name)s" was reverted successfully. You may edit it again below.') % {"model": force_unicode(opts.verbose_name), "name": unicode(obj)})
- # Redirect to the model change form.
- if revert:
- return HttpResponseRedirect("../../")
- elif recover:
- return HttpResponseRedirect("../../%s/" % quote(object_id))
- else:
- assert False
- else:
- # This is a mutated version of the code in the standard model admin
- # change_view. Once again, a hook for this kind of functionality
- # would be nice. Unfortunately, it results in doubling the number
- # of queries required to construct the formets.
- form = ModelForm(instance=obj, initial=self.get_revision_form_data(request, obj, version))
- prefixes = {}
- for FormSet, inline in zip(self.get_formsets(request, obj), self.inline_instances):
- # This code is standard for creating the formset.
- prefix = FormSet.get_default_prefix()
- prefixes[prefix] = prefixes.get(prefix, 0) + 1
- if prefixes[prefix] != 1:
- prefix = "%s-%s" % (prefix, prefixes[prefix])
- formset = FormSet(instance=obj, prefix=prefix,
- queryset=inline.queryset(request))
- self._hack_inline_formset_initial(FormSet, formset, obj, version, revert, recover)
- # Add this hacked formset to the form.
- formsets.append(formset)
- # Generate admin form helper.
- adminForm = helpers.AdminForm(form, self.get_fieldsets(request, obj),
- self.prepopulated_fields, self.get_readonly_fields(request, obj),
- model_admin=self)
- media = self.media + adminForm.media
- # Generate formset helpers.
- inline_admin_formsets = []
- for inline, formset in zip(self.inline_instances, formsets):
- fieldsets = list(inline.get_fieldsets(request, obj))
- readonly = list(inline.get_readonly_fields(request, obj))
- inline_admin_formset = helpers.InlineAdminFormSet(inline, formset,
- fieldsets, readonly, model_admin=self)
- inline_admin_formsets.append(inline_admin_formset)
- media = media + inline_admin_formset.media
- # Generate the context.
- context.update({"adminform": adminForm,
- "object_id": object_id,
- "original": obj,
- "is_popup": False,
- "media": mark_safe(media),
- "inline_admin_formsets": inline_admin_formsets,
- "errors": helpers.AdminErrorList(form, formsets),
- "app_label": opts.app_label,
- "add": False,
- "change": True,
- "revert": revert,
- "recover": recover,
- "has_add_permission": self.has_add_permission(request),
- "has_change_permission": self.has_change_permission(request, obj),
- "has_delete_permission": self.has_delete_permission(request, obj),
- "has_file_field": True,
- "has_absolute_url": False,
- "ordered_objects": opts.get_ordered_objects(),
- "form_url": mark_safe(request.path),
- "opts": opts,
- "content_type_id": ContentType.objects.get_for_model(self.model).id,
- "save_as": False,
- "save_on_top": self.save_on_top,
- "changelist_url": reverse("%s:%s_%s_changelist" % (self.admin_site.name, opts.app_label, opts.module_name)),
- "change_url": reverse("%s:%s_%s_change" % (self.admin_site.name, opts.app_label, opts.module_name), args=(quote(obj.pk),)),
- "history_url": reverse("%s:%s_%s_history" % (self.admin_site.name, opts.app_label, opts.module_name), args=(quote(obj.pk),)),
- "recoverlist_url": reverse("%s:%s_%s_recoverlist" % (self.admin_site.name, opts.app_label, opts.module_name))})
- # Render the form.
- if revert:
- form_template = self.revision_form_template or self._get_template_list("revision_form.html")
- elif recover:
- form_template = self.recover_form_template or self._get_template_list("recover_form.html")
- else:
- assert False
- return render_to_response(form_template, context, template.RequestContext(request))
-
- @transaction.commit_on_success
- @revision_context_manager.create_revision()
- def recover_view(self, request, version_id, extra_context=None):
- """Displays a form that can recover a deleted model."""
- version = get_object_or_404(Version, pk=version_id)
- obj = version.object_version.object
- context = {"title": _("Recover %(name)s") % {"name": version.object_repr},}
- context.update(extra_context or {})
- return self.render_revision_form(request, obj, version, context, recover=True)
-
- @transaction.commit_on_success
- @revision_context_manager.create_revision()
- def revision_view(self, request, object_id, version_id, extra_context=None):
- """Displays the contents of the given revision."""
- object_id = unquote(object_id) # Underscores in primary key get quoted to "_5F"
- obj = get_object_or_404(self.model, pk=object_id)
- version = get_object_or_404(Version, pk=version_id, object_id=unicode(obj.pk))
- # Generate the context.
- context = {"title": _("Revert %(name)s") % {"name": force_unicode(self.model._meta.verbose_name)},}
- context.update(extra_context or {})
- return self.render_revision_form(request, obj, version, context, revert=True)
-
- @transaction.commit_on_success
- @revision_context_manager.create_revision()
- def add_view(self, *args, **kwargs):
- """Adds a new model to the application."""
- return super(VersionAdmin, self).add_view(*args, **kwargs)
-
- @transaction.commit_on_success
- @revision_context_manager.create_revision()
- def change_view(self, *args, **kwargs):
- """Modifies an existing model."""
- return super(VersionAdmin, self).change_view(*args, **kwargs)
-
- @transaction.commit_on_success
- @revision_context_manager.create_revision()
- def delete_view(self, *args, **kwargs):
- """Deletes an existing model."""
- return super(VersionAdmin, self).delete_view(*args, **kwargs)
-
- @transaction.commit_on_success
- @revision_context_manager.create_revision()
- def changelist_view(self, request, extra_context=None):
- """Renders the change view."""
- opts = self.model._meta
- context = {"recoverlist_url": reverse("%s:%s_%s_recoverlist" % (self.admin_site.name, opts.app_label, opts.module_name)),
- "add_url": reverse("%s:%s_%s_add" % (self.admin_site.name, opts.app_label, opts.module_name)),}
- context.update(extra_context or {})
- return super(VersionAdmin, self).changelist_view(request, context)
-
- def history_view(self, request, object_id, extra_context=None):
- """Renders the history view."""
- object_id = unquote(object_id) # Underscores in primary key get quoted to "_5F"
- opts = self.model._meta
- action_list = [
- {
- "revision": version.revision,
- "url": reverse("%s:%s_%s_revision" % (self.admin_site.name, opts.app_label, opts.module_name), args=(quote(version.object_id), version.id)),
- }
- for version
- in self._order_version_queryset(self.revision_manager.get_for_object_reference(
- self.model,
- object_id,
- ).select_related("revision__user"))
- ]
- # Compile the context.
- context = {"action_list": action_list}
- context.update(extra_context or {})
- return super(VersionAdmin, self).history_view(request, object_id, context)
-
-
-class VersionMetaAdmin(VersionAdmin):
-
- """
- An enhanced VersionAdmin that annotates the given object with information about
- the last version that was saved.
- """
-
- def __init__(self, *args, **kwargs):
- """Initializes the VersionMetaAdmin."""
- super(VersionMetaAdmin, self).__init__(*args, **kwargs)
- # Check that the model has an int pk.
- if not has_int_pk(self.model):
- raise ImproperlyConfigured("Cannot use VersionMetaAdmin unless the model has an integer primary key.")
-
- def queryset(self, request):
- """Returns the annotated queryset."""
- content_type = ContentType.objects.get_for_model(self.model)
- pk = self.model._meta.pk
- return super(VersionMetaAdmin, self).queryset(request).extra(
- select = {
- "date_modified": """
- SELECT MAX(%(revision_table)s.date_created)
- FROM %(version_table)s
- JOIN %(revision_table)s ON %(revision_table)s.id = %(version_table)s.revision_id
- WHERE %(version_table)s.content_type_id = %%s AND %(version_table)s.object_id_int = %(table)s.%(pk)s
- """ % {
- "revision_table": connection.ops.quote_name(Revision._meta.db_table),
- "version_table": connection.ops.quote_name(Version._meta.db_table),
- "table": connection.ops.quote_name(self.model._meta.db_table),
- "pk": connection.ops.quote_name(pk.db_column or pk.attname),
- }
- },
- select_params = (content_type.id,),
- )
-
- def get_date_modified(self, obj):
- """Displays the last modified date of the given object, typically for use in a change list."""
- return format(obj.date_modified, _('DATETIME_FORMAT'))
- get_date_modified.short_description = "date modified"
View
82 edtrac_project/django_reversion/reversion/helpers.py
@@ -1,82 +0,0 @@
-"""A number of useful helper functions to automate common tasks."""
-
-
-from django.contrib import admin
-from django.contrib.admin.sites import NotRegistered
-
-from reversion.admin import VersionAdmin
-
-
-def patch_admin(model, admin_site=None):
- """
- Enables version control with full admin integration for a model that has
- already been registered with the django admin site.
-
- This is excellent for adding version control to existing Django contrib
- applications.
- """
- admin_site = admin_site or admin.site
- try:
- ModelAdmin = admin_site._registry[model].__class__
- except KeyError:
- raise NotRegistered, "The model %r has not been registered with the admin site." % model
- # Unregister existing admin class.
- admin_site.unregister(model)
- # Register patched admin class.
- class PatchedModelAdmin(VersionAdmin, ModelAdmin):
- pass
- admin_site.register(model, PatchedModelAdmin)
-
-
-# Patch generation methods, only available if the google-diff-match-patch
-# library is installed.
-#
-# http://code.google.com/p/google-diff-match-patch/
-
-
-try:
- from diff_match_patch import diff_match_patch
-except ImportError:
- pass
-else:
- dmp = diff_match_patch()
-
- def generate_diffs(old_version, new_version, field_name, cleanup):
- """Generates a diff array for the named field between the two versions."""
- # Extract the text from the versions.
- old_text = old_version.field_dict[field_name] or u""
- new_text = new_version.field_dict[field_name] or u""
- # Generate the patch.
- diffs = dmp.diff_main(unicode(old_text), unicode(new_text))
- if cleanup == "semantic":
- dmp.diff_cleanupSemantic(diffs)
- elif cleanup == "efficiency":
- dmp.diff_cleanupEfficiency(diffs)
- elif cleanup is None:
- pass
- else:
- raise ValueError("cleanup parameter should be one of 'semantic', 'efficiency' or None.")
- return diffs
-
- def generate_patch(old_version, new_version, field_name, cleanup=None):
- """
- Generates a text patch of the named field between the two versions.
-
- The cleanup parameter can be None, "semantic" or "efficiency" to clean up the diff
- for greater human readibility.
- """
- diffs = generate_diffs(old_version, new_version, field_name, cleanup)
- patch = dmp.patch_make(diffs)
- return dmp.patch_toText(patch)
-
- def generate_patch_html(old_version, new_version, field_name, cleanup=None):
- """
- Generates a pretty html version of the differences between the named
- field in two versions.
-
- The cleanup parameter can be None, "semantic" or "efficiency" to clean up the diff
- for greater human readibility.
- """
- diffs = generate_diffs(old_version, new_version, field_name, cleanup)
- return dmp.diff_prettyHtml(diffs)
-
View
BIN edtrac_project/django_reversion/reversion/locale/cs/LC_MESSAGES/django.mo
Binary file not shown.
View
128 edtrac_project/django_reversion/reversion/locale/cs/LC_MESSAGES/django.po
@@ -1,128 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-01-12 11:13+0100\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n>1 && n<5 ? 1 : 2;\n"
-
-#: admin.py:112 templates/reversion/change_list.html:8
-#: templates/reversion/recover_list.html:10
-#, python-format
-msgid "Recover deleted %(name)s"
-msgstr "Obnovit smazané %(name)s"
-
-#: admin.py:165
-#, python-format
-msgid "Reverted to previous version, saved on %(datetime)s"
-msgstr "Vrátit se k předchozí verzi uložené v %(datetime)s"
-
-#: admin.py:167
-#, python-format
-msgid ""
-"The %(model)s \"%(name)s\" was reverted successfully. You may edit it again "
-"below."
-msgstr ""
-"Objekt %(model)s \"%(name)s\" byl úspěšně obnoven. Můžete ho znovu začít upravovat "
-"níže."
-
-#: admin.py:273
-#, python-format
-msgid "Recover %(name)s"
-msgstr "Obnovit %(name)s"
-
-#: admin.py:284
-#, python-format
-msgid "Revert %(name)s"
-msgstr "Navrátit se k předchozí verzi %(name)s"
-
-#: management/commands/createinitialrevisions.py:76
-msgid "Initial version."
-msgstr ""
-
-#: templates/reversion/change_list.html:11
-#, python-format
-msgid "Add %(name)s"
-msgstr "Přidat %(name)s"
-
-#: templates/reversion/object_history.html:8
-msgid ""
-"Choose a date from the list below to revert to a previous version of this "
-"object."
-msgstr ""
-"Zvolte datum ze seznamu níže pro návrat k předchozí verzi tohoto objektu."
-
-#: templates/reversion/object_history.html:15
-#: templates/reversion/recover_list.html:23
-msgid "Date/time"
-msgstr "Datum/čas"
-
-#: templates/reversion/object_history.html:16
-msgid "User"
-msgstr "Uživatel"
-
-#: templates/reversion/object_history.html:17
-msgid "Comment"
-msgstr "Komentář"
-
-#: templates/reversion/object_history.html:23
-#: templates/reversion/recover_list.html:30
-msgid "DATETIME_FORMAT"
-msgstr "DATETIME_FORMAT"
-
-#: templates/reversion/object_history.html:31
-msgid ""
-"This object doesn't have a change history. It probably wasn't added via this "
-"admin site."
-msgstr ""
-"Tento objekt nemá uloženou žádnou historii změn. Zřejmě nebyl přidát přes toto "
-"administrační rozhraní."
-
-#: templates/reversion/recover_form.html:7
-#: templates/reversion/recover_list.html:7
-#: templates/reversion/revision_form.html:10
-msgid "Home"
-msgstr "Domů"
-
-#: templates/reversion/recover_form.html:10
-#, python-format
-msgid "Recover deleted %(verbose_name)s"
-msgstr "Obnovit smazané %(verbose_name)s"
-
-#: templates/reversion/recover_form.html:17
-msgid "Press the save button below to recover this version of the object."
-msgstr "Klikněte na tlačítko uložit pro obnovení této verze objektu."
-
-#: templates/reversion/recover_list.html:17
-msgid ""
-"Choose a date from the list below to recover a deleted version of an object."
-msgstr ""
-"Zvolte datum ze seznamu níže pro obnovení smazané verze objektu."
-
-#: templates/reversion/recover_list.html:37
-msgid "There are no deleted objects to recover."
-msgstr "Žádné smazané objekty k obnovení."
-
-#: templates/reversion/revision_form.html:14
-msgid "History"
-msgstr "Historie"
-
-#: templates/reversion/revision_form.html:15
-#, python-format
-msgid "Revert %(verbose_name)s"
-msgstr "Navrátit %(verbose_name)s k předchozí verzi"
-
-#: templates/reversion/revision_form.html:28
-msgid "Press the save button below to revert to this version of the object."
-msgstr "Klikněte na tlačítko uložit pro návrat k této verze objektu."
View
BIN edtrac_project/django_reversion/reversion/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
View
129 edtrac_project/django_reversion/reversion/locale/de/LC_MESSAGES/django.po
@@ -1,129 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: reversion\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-02-03 08:31+0100\n"
-"PO-Revision-Date: 2009-02-03 08:41+0100\n"
-"Last-Translator: Jannis Leidel <jannis@leidel.info>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: admin.py:122 templates/reversion/change_list.html:8
-#: templates/reversion/recover_list.html:9
-#, python-format
-msgid "Recover deleted %(name)s"
-msgstr "Gelöschte %(name)s wiederherstellen"
-
-#: admin.py:155
-#, python-format
-msgid "Reverted to previous version, saved on %(datetime)s"
-msgstr "Zu vorheriger Version zurückgesetzt, %(datetime)s gespeichert"
-
-#: admin.py:157
-#, python-format
-msgid ""
-"The %(model)s \"%(name)s\" was reverted successfully. You may edit it again "
-"below."
-msgstr ""
-"%(model)s \"%(name)s\" wurde erfolgreich zurückgesetzt. Sie können mit der "
-"Bearbeitung forfahren."
-
-#: admin.py:227
-#, python-format
-msgid "Recover %s"
-msgstr "%s wiederherstellen"
-
-#: admin.py:243
-#, python-format
-msgid "Revert %(name)s"
-msgstr "%(name)s zurücksetzen"
-
-#: templates/reversion/change_list.html:11
-#, python-format
-msgid "Add %(name)s"
-msgstr "%(name)s hinzufügen"
-
-#: templates/reversion/object_history.html:8
-msgid ""
-"Choose a date from the list below to revert to a previous version of this "
-"object."
-msgstr ""
-"Wählen Sie einen Zeitpunkt aus der untenstehenden Liste aus, um zu einer "
-"vorherigen Version dieses Objektes zurückzukehren."
-
-#: templates/reversion/object_history.html:15
-#: templates/reversion/recover_list.html:21
-msgid "Date/time"
-msgstr "Datum/Zeit"
-
-#: templates/reversion/object_history.html:16
-msgid "User"
-msgstr "Benutzer"
-
-#: templates/reversion/object_history.html:17
-msgid "Comment"
-msgstr "Kommentar"
-
-#: templates/reversion/object_history.html:23
-#: templates/reversion/recover_list.html:28
-msgid "DATETIME_FORMAT"
-msgstr "j. N Y, H:i"
-
-#: templates/reversion/object_history.html:31
-msgid ""
-"This object doesn't have a change history. It probably wasn't added via this "
-"admin site."
-msgstr ""
-"Dieses Objekt hat keine Änderungsgeschichte. Es wurde möglicherweise nicht "
-"über diese Verwaltungsseiten angelegt."
-
-#: templates/reversion/recover_form.html:14
-#: templates/reversion/recover_list.html:6
-#: templates/reversion/revision_form.html:14
-msgid "Home"
-msgstr "Start"
-
-#: templates/reversion/recover_form.html:17
-#, python-format
-msgid "Recover deleted %(verbose_name)s"
-msgstr "Gelöschte %(verbose_name)s wiederherstellen"
-
-#: templates/reversion/recover_form.html:18
-#, python-format
-msgid "Recover %(name)s"
-msgstr "%(name)s wiederherstellen"
-
-#: templates/reversion/recover_form.html:24
-msgid "Press the save button below to recover this version of the object."
-msgstr "Sichern Sie, um diese Version des Objektes wiederherzustellen."
-
-#: templates/reversion/recover_list.html:15
-msgid ""
-"Choose a date from the list below to recover a deleted version of an object."
-msgstr ""
-"Wählen Sie einen Zeitpunk aus der untenstehenden Liste, um eine gelöschte "
-"Version des Objektes wiederherzustellen."
-
-#: templates/reversion/recover_list.html:35
-msgid "There are no deleted objects to recover."
-msgstr "Es sind keine gelöschten Objekte zur Wiederherstellung vorhanden."
-
-#: templates/reversion/revision_form.html:18
-msgid "History"
-msgstr "Geschichte"
-
-#: templates/reversion/revision_form.html:19
-#, python-format
-msgid "Revert %(verbose_name)s"
-msgstr "%(verbose_name)s zurücksetzen"
-
-#: templates/reversion/revision_form.html:32
-msgid "Press the save button below to revert to this version of the object."
-msgstr "Sichern Sie, um das Objekt zu dieser Version zurückzusetzen."
View
BIN edtrac_project/django_reversion/reversion/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
View
127 edtrac_project/django_reversion/reversion/locale/fr/LC_MESSAGES/django.po
@@ -1,127 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# Simon Charette <charette.s@gmail.com>, 2010.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-10-01 20:56-0400\n"
-"PO-Revision-Date: 2011-09-21 16:31-0400\n"
-"Last-Translator: Etienne Desautels <etienne.desautels@gmail.com>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"Language: fr\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=n>1;\n"
-
-#: admin.py:143 templates/reversion/change_list.html:7
-#: templates/reversion/recover_form.html:10
-#: templates/reversion/recover_list.html:10
-#, python-format
-msgid "Recover deleted %(name)s"
-msgstr "Récupérer %(name)s supprimés"
-
-#: admin.py:123
-#, python-format
-msgid "Deleted %(verbose_name)s."
-msgstr "Supprimé %(verbose_name)s."
-
-#: admin.py:252
-#, python-format
-msgid "Reverted to previous version, saved on %(datetime)s"
-msgstr "Restauré depuis une version précédente, sauvée le %(datetime)s"
-
-#: admin.py:254
-#, python-format
-msgid ""
-"The %(model)s \"%(name)s\" was reverted successfully. You may edit it again "
-"below."
-msgstr ""
-"L’élément %(model)s \"%(name)s\" a été restauré avec succès. Vous pouvez "
-"l’éditer à nouveau."
-
-#: admin.py:337
-#, python-format
-msgid "Recover %(name)s"
-msgstr "Récupérer %(name)s"
-
-#: admin.py:349
-#, python-format
-msgid "Revert %(name)s"
-msgstr "Restaurer %(name)s"
-
-#: admin.py:111
-msgid "Initial version."
-msgstr "Version initiale."
-
-#: templates/reversion/object_history.html:8
-msgid ""
-"Choose a date from the list below to revert to a previous version of this "
-"object."
-msgstr "Choisissez une date dans la liste ci-dessous afin de restaurer "
-"une version précédente de cet élément."
-
-#: templates/reversion/object_history.html:15
-#: templates/reversion/recover_list.html:23
-msgid "Date/time"
-msgstr "Date/heure"
-
-#: templates/reversion/object_history.html:16
-msgid "User"
-msgstr "Utilisateur"
-
-#: templates/reversion/object_history.html:17
-msgid "Comment"
-msgstr "Commentaire"
-
-#: admin.py:252 templates/reversion/object_history.html:23
-#: templates/reversion/recover_list.html:30
-msgid "DATETIME_FORMAT"
-msgstr "j F Y H:i:s"
-
-#: templates/reversion/object_history.html:36
-msgid ""
-"This object doesn't have a change history. It probably wasn't added via this "
-"admin site."
-msgstr ""
-"Cet élément ne possède pas d’historique de modifications. Il n’a "
-"probablement pas été ajouté à partir de ce site d’administration."
-
-#: templates/reversion/recover_form.html:7
-#: templates/reversion/recover_list.html:7
-#: templates/reversion/revision_form.html:7
-msgid "Home"
-msgstr "Accueil"
-
-#: templates/reversion/recover_form.html:17
-msgid "Press the save button below to recover this version of the object."
-msgstr "Cliquez sur le bouton <strong>Enregistrer</strong> ci-dessous afin de "
-"récupérer cet élément."
-
-#: templates/reversion/recover_list.html:17
-msgid ""
-"Choose a date from the list below to recover a deleted version of an object."
-msgstr "Choisissez une date dans la liste ci-dessous afin de récupérer un "
-"élément supprimé."
-
-#: templates/reversion/recover_list.html:37
-msgid "There are no deleted objects to recover."
-msgstr "Il n’y a pas d’éléments supprimés à récupérer."
-
-#: templates/reversion/revision_form.html:11
-msgid "History"
-msgstr "Historique"
-
-#: templates/reversion/revision_form.html:12
-#, python-format
-msgid "Revert %(verbose_name)s"
-msgstr "Restaurer %(verbose_name)s"
-
-#: templates/reversion/revision_form.html:25
-msgid "Press the save button below to revert to this version of the object."
-msgstr "Cliquez sur le bouton <strong>Enregistrer</strong> ci-dessous pour "
-"restaurer cette version de l’élément."
View
BIN edtrac_project/django_reversion/reversion/locale/he/LC_MESSAGES/django.mo
Binary file not shown.
View
123 edtrac_project/django_reversion/reversion/locale/he/LC_MESSAGES/django.po
@@ -1,123 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-12-10 10:27+0200\n"
-"PO-Revision-Date: 2009-12-10 10:45+0200\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: admin.py:112 templates/reversion/change_list.html:7
-#: templates/reversion/recover_list.html:10
-#, python-format
-msgid "Recover deleted %(name)s"
-msgstr "שחזור %(name)s שנמחקו"
-
-#: admin.py:158
-#, python-format
-msgid "Reverted to previous version, saved on %(datetime)s"
-msgstr "שוחזר לגרסה קודמת, נשמרה ב-%(datetime)s"
-
-#: admin.py:160
-#, python-format
-msgid ""
-"The %(model)s \"%(name)s\" was reverted successfully. You may edit it again "
-"below."
-msgstr ""
-"שחזור %(model)s \"%(name)s\" לגרסה קודמת הצליח. ניתן לערוך שוב "
-"מתחת."
-
-#: admin.py:259
-#, python-format
-msgid "Recover %(name)s"
-msgstr "אחזור %(name)s"
-
-#: admin.py:269
-#, python-format
-msgid "Revert %(name)s"
-msgstr "שחזור %(name)s"
-
-#: templates/reversion/change_list.html:9
-#, python-format
-msgid "Add %(name)s"
-msgstr "הוספת %(name)s"
-
-#: templates/reversion/object_history.html:8
-msgid ""
-"Choose a date from the list below to revert to a previous version of this "
-"object."
-msgstr ""
-"נא לבחור תאריך מהרשימה להלן כדי לשחזר לגרסה קודמת של "
-"אובייקט זה."
-
-#: templates/reversion/object_history.html:15
-#: templates/reversion/recover_list.html:23
-msgid "Date/time"
-msgstr "תאריך/שעה"
-
-#: templates/reversion/object_history.html:16
-msgid "User"
-msgstr "משתמש"
-
-#: templates/reversion/object_history.html:17
-msgid "Comment"
-msgstr "הערה"
-
-#: templates/reversion/object_history.html:23
-#: templates/reversion/recover_list.html:30
-msgid "DATETIME_FORMAT"
-msgstr "d.m.‏Y H:i:s"
-
-#: templates/reversion/object_history.html:31
-msgid ""
-"This object doesn't have a change history. It probably wasn't added via this "
-"admin site."
-msgstr ""
-"לאובייקט זה אין היסטוריית שינוי. כנראה לא התווסף דרך "
-"ממשק הניהול."
-
-#: templates/reversion/recover_form.html:14
-#: templates/reversion/recover_list.html:7
-#: templates/reversion/revision_form.html:14
-msgid "Home"
-msgstr "ראשי"
-
-#: templates/reversion/recover_form.html:17
-#, python-format
-msgid "Recover deleted %(verbose_name)s"
-msgstr "אחזור %(verbose_name)s שנמחק"
-
-#: templates/reversion/recover_form.html:24
-msgid "Press the save button below to recover this version of the object."
-msgstr "נא ללחוץ על לחצן השמירה מתחת כדי לאחזר לגרסה זו של האובייקט"
-
-#: templates/reversion/recover_list.html:17
-msgid ""
-"Choose a date from the list below to recover a deleted version of an object."
-msgstr ""
-"נא לבחור תאריך מתחת כדי לאחזר גרסה מחוקה של אובייקט"
-
-#: templates/reversion/recover_list.html:37
-msgid "There are no deleted objects to recover."
-msgstr "אין אובייקטים מחוקים לאחזור"
-
-#: templates/reversion/revision_form.html:18
-msgid "History"
-msgstr "היסטוריה"
-
-#: templates/reversion/revision_form.html:19
-#, python-format
-msgid "Revert %(verbose_name)s"
-msgstr "שחזור %(verbose_name)s"
-
-#: templates/reversion/revision_form.html:32
-msgid "Press the save button below to revert to this version of the object."
-msgstr "נא ללחוץ על לחצן השמירה מתחת כדי לשחזר לגרסה זו של האובייקט"
View
BIN edtrac_project/django_reversion/reversion/locale/it/LC_MESSAGES/django.mo
Binary file not shown.
View
113 edtrac_project/django_reversion/reversion/locale/it/LC_MESSAGES/django.po
@@ -1,113 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: PACKAGE VERSION\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-08-29 13:04+0200\n"
-"PO-Revision-Date: 2009-08-29 13:44+0100\n"
-"Last-Translator: Marco Beri <marcoberi@gmail.com>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: .\admin.py:128
-#: .\templates\reversion\change_list.html.py:7
-#: .\templates\reversion\recover_list.html.py:10
-msgid "Recover deleted %(name)s"
-msgstr "Recupera %(name)s cancellati"
-
-#: .\admin.py:173
-#, python-format
-msgid "Reverted to previous version, saved on %(datetime)s"
-msgstr "Ritorna alla precedente versione, salvata il %(datetime)s"
-
-#: .\admin.py:175
-#, python-format
-msgid "The %(model)s \"%(name)s\" was reverted successfully. You may edit it again below."
-msgstr "%(model)s \"%(name)s\" è alla versione precedente. Puoi effettuare nuove modifiche se lo desideri."
-
-#: .\admin.py:271
-#, python-format
-msgid "Recover %(name)s"
-msgstr "Recupera %(name)s"
-
-#: .\admin.py:281
-#, python-format
-msgid "Revert %(name)s"
-msgstr "Ritorna %(name)s"
-
-#: .\templates\reversion\change_list.html.py:9
-#, python-format
-msgid "Add %(name)s"
-msgstr "Aggiungi %(name)s"
-
-#: .\templates\reversion\object_history.html.py:8
-msgid "Choose a date from the list below to revert to a previous version of this object."
-msgstr "Scegli una data dall'elenco qui sotto per ritornare a una precedente versione di questo oggetto."
-
-#: .\templates\reversion\object_history.html.py:15
-#: .\templates\reversion\recover_list.html.py:23
-msgid "Date/time"
-msgstr "Data/ora"
-
-#: .\templates\reversion\object_history.html.py:16
-msgid "User"
-msgstr "Utente"
-
-#: .\templates\reversion\object_history.html.py:17
-msgid "Comment"
-msgstr "Commento"
-
-#: .\templates\reversion\object_history.html.py:23
-#: .\templates\reversion\recover_list.html.py:30
-msgid "DATETIME_FORMAT"
-msgstr "d/m/Y, G:i"
-
-#: .\templates\reversion\object_history.html.py:31
-msgid "This object doesn't have a change history. It probably wasn't added via this admin site."
-msgstr "Questo oggetto non ha una storia di modifiche. Probabilmente non è stato aggiunto attraverso questo sito di Admin."
-
-#: .\templates\reversion\recover_form.html.py:14
-#: .\templates\reversion\recover_list.html.py:7
-#: .\templates\reversion\revision_form.html.py:14
-msgid "Home"
-msgstr "Home"
-
-#: .\templates\reversion\recover_form.html.py:17
-#, python-format
-msgid "Recover deleted %(verbose_name)s"
-msgstr "Recupera %(verbose_name)s cancellato"
-
-#: .\templates\reversion\recover_form.html.py:24
-msgid "Press the save button below to recover this version of the object."
-msgstr "Premi il pulsante Salva in basso per recuperare questa versione dell'oggetto."
-
-#: .\templates\reversion\recover_list.html.py:17
-msgid "Choose a date from the list below to recover a deleted version of an object."
-msgstr "Scegli una data dall'elenco qui sotto per recuperare una versione cancellata di questo oggetto."
-
-#: .\templates\reversion\recover_list.html.py:37
-msgid "There are no deleted objects to recover."
-msgstr "Non ci sono oggetti cancellati da recuperare."
-
-#: .\templates\reversion\revision_form.html.py:18
-msgid "History"
-msgstr "Storia"
-
-#: .\templates\reversion\revision_form.html.py:19
-#, python-format
-msgid "Revert %(verbose_name)s"
-msgstr "Ritorna %(verbose_name)s"
-
-#: .\templates\reversion\revision_form.html.py:32
-msgid "Press the save button below to revert to this version of the object."
-msgstr "Premi il pulsante Salva in basso per ritornare a questa versione dell'oggetto"
-
-#~ msgid "Recover %s"
-#~ msgstr "Recupera %s"
-
View
BIN edtrac_project/django_reversion/reversion/locale/nb/LC_MESSAGES/django.mo
Binary file not shown.
View
116 edtrac_project/django_reversion/reversion/locale/nb/LC_MESSAGES/django.po
@@ -1,116 +0,0 @@
-# Norwegian translation for django-reversion
-# This file is distributed under the same license as the django-reversion package.
-# Sindre Sorhus <sindresorhus@gmail.com>, 2011.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: django-reversion\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-10-17 09:34+0200\n"
-"PO-Revision-Date: 2011-10-17 10:17+0100\n"
-"Last-Translator: Sindre Sorhus <sindresorhus@gmail.com>\n"
-"Language-Team: \n"
-"Language: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1)\n"
-"X-Poedit-Language: Norwegian Bokmal\n"
-"X-Poedit-Country: NORWAY\n"
-"X-Poedit-SourceCharset: utf-8\n"
-
-#: admin.py:111
-msgid "Initial version."
-msgstr "Initial versjon"
-
-#: admin.py:125
-#, python-format
-msgid "Deleted %(verbose_name)s."
-msgstr "Slettet %(verbose_name)s."
-
-#: admin.py:143
-#: templates/reversion/change_list.html:7
-#: templates/reversion/recover_form.html:10
-#: templates/reversion/recover_list.html:10
-#, python-format
-msgid "Recover deleted %(name)s"
-msgstr "Gjenopprett slettede %(name)s"
-
-#: admin.py:252
-#, python-format
-msgid "Reverted to previous version, saved on %(datetime)s"
-msgstr "Gjenopprettet til forrige versjon, lagret den %(datetime)s"
-
-#: admin.py:252
-#: templates/reversion/object_history.html:23
-#: templates/reversion/recover_list.html:30
-msgid "DATETIME_FORMAT"
-msgstr "j. F Y H:i"
-
-#: admin.py:254
-#, python-format
-msgid "The %(model)s \"%(name)s\" was reverted successfully. You may edit it again below."
-msgstr "%(model)s \"%(name)s\" ble gjenopprettet. Du kan redigere den igjen nedenfor."
-
-#: admin.py:337
-#, python-format
-msgid "Recover %(name)s"
-msgstr "Gjenopprett %(name)s"
-
-#: admin.py:349
-#, python-format
-msgid "Revert %(name)s"
-msgstr "Tilbakestill %(name)s"
-
-#: templates/reversion/object_history.html:8
-msgid "Choose a date from the list below to revert to a previous version of this object."
-msgstr "Velg en dato fra listen nedenfor for å gå tilbake til en tidligere versjon av dette objektet."
-
-#: templates/reversion/object_history.html:15
-#: templates/reversion/recover_list.html:23
-msgid "Date/time"
-msgstr "Dato/tid"
-
-#: templates/reversion/object_history.html:16
-msgid "User"
-msgstr "Bruker"
-
-#: templates/reversion/object_history.html:17
-msgid "Comment"
-msgstr "Kommentar"
-
-#: templates/reversion/object_history.html:36
-msgid "This object doesn't have a change history. It probably wasn't added via this admin site."
-msgstr "Dette objektet har ingen endringshistorie. Objektet er sannsynligvis ikke blitt lagt inn via dette admin nettstedet."
-
-#: templates/reversion/recover_form.html:7
-#: templates/reversion/recover_list.html:7
-#: templates/reversion/revision_form.html:7
-msgid "Home"
-msgstr "Hjem"
-
-#: templates/reversion/recover_form.html:17
-msgid "Press the save button below to recover this version of the object."
-msgstr "Trykk på lagre-knappen nedenfor for å gjenopprette denne versjonen av objektet."
-
-#: templates/reversion/recover_list.html:17
-msgid "Choose a date from the list below to recover a deleted version of an object."
-msgstr "Velg en dato fra listen nedenfor for å gjenopprette en slettet versjon av et objekt."
-
-#: templates/reversion/recover_list.html:37
-msgid "There are no deleted objects to recover."
-msgstr "Finner ingen slettede objekter å gjenopprette."
-
-#: templates/reversion/revision_form.html:11
-msgid "History"
-msgstr "Historie"
-
-#: templates/reversion/revision_form.html:12
-#, python-format
-msgid "Revert %(verbose_name)s"
-msgstr "Tilbakestill %(verbose_name)s"
-
-#: templates/reversion/revision_form.html:25
-msgid "Press the save button below to revert to this version of the object."
-msgstr "Trykk på lagre-knappen under for å gå tilbake til denne versjonen av objektet."
-
View
BIN edtrac_project/django_reversion/reversion/locale/pl/LC_MESSAGES/django.mo
Binary file not shown.
View
124 edtrac_project/django_reversion/reversion/locale/pl/LC_MESSAGES/django.po
@@ -1,124 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: reversion\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-03-21 20:05+0100\n"
-"PO-Revision-Date: 2011-03-21 20:12+0100\n"
-"Last-Translator: Zbigniew Siciarz <zbigniew@siciarz.net>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"Language: pl\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: admin.py:100
-msgid "Initial version."
-msgstr "Pierwsza wersja."
-
-#: admin.py:115
-#, python-format
-msgid "Deleted %(verbose_name)s."
-msgstr "Usunięto %(verbose_name)s"
-
-#: admin.py:127
-#: templates/reversion/change_list.html:8
-#: templates/reversion/recover_list.html:10
-#, python-format
-msgid "Recover deleted %(name)s"
-msgstr "Odzyskaj usunięte %(name)s"
-
-#: admin.py:218
-#, python-format
-msgid "Reverted to previous version, saved on %(datetime)s"
-msgstr "Przywrócono poprzednią wersję, zapisaną %(datetime)s"
-
-#: admin.py:220
-#, python-format
-msgid "The %(model)s \"%(name)s\" was reverted successfully. You may edit it again below."
-msgstr "%(model)s \"%(name)s\" został pomyślnie przywrócony. Możesz go ponownie edytować poniżej."
-
-#: admin.py:321
-#, python-format
-msgid "Recover %(name)s"
-msgstr "Przywróć %(name)s"
-
-#: admin.py:332
-#, python-format
-msgid "Revert %(name)s"
-msgstr "Przywróć %(name)s"
-
-#: templates/reversion/change_list.html:11
-#, python-format
-msgid "Add %(name)s"
-msgstr "Dodaj %(name)s"
-
-#: templates/reversion/object_history.html:8
-msgid "Choose a date from the list below to revert to a previous version of this object."
-msgstr "Wybierz datę z poniższej listy, by przywrócić ten obiekt do poprzedniej wersji."
-
-#: templates/reversion/object_history.html:15
-#: templates/reversion/recover_list.html:23
-msgid "Date/time"
-msgstr "Data/czas"
-
-#: templates/reversion/object_history.html:16
-msgid "User"
-msgstr "Użytkownik"
-
-#: templates/reversion/object_history.html:17
-msgid "Comment"
-msgstr "Komentarz"
-
-#: templates/reversion/object_history.html:23
-#: templates/reversion/recover_list.html:30
-msgid "DATETIME_FORMAT"
-msgstr "j. N Y, H:i"
-
-#: templates/reversion/object_history.html:31
-msgid "This object doesn't have a change history. It probably wasn't added via this admin site."
-msgstr "Ten obiekt nie posiada historii zmian. Prawdopodobnie nie został dodany za pomocą tego panelu administracyjnego."
-
-#: templates/reversion/recover_form.html:7
-#: templates/reversion/recover_list.html:7
-#: templates/reversion/revision_form.html:10
-msgid "Home"
-msgstr "Strona główna"
-
-#: templates/reversion/recover_form.html:10
-#, python-format
-msgid "Recover deleted %(verbose_name)s"
-msgstr "Przywróć usunięte %(verbose_name)s"
-
-#: templates/reversion/recover_form.html:17
-msgid "Press the save button below to recover this version of the object."
-msgstr "Naciśnij przycisk Zapisz poniżej, by przywrócić tę wersję obiektu."
-
-#: templates/reversion/recover_list.html:17
-msgid "Choose a date from the list below to recover a deleted version of an object."
-msgstr "Wybierz datę z poniższej listy, by przywrócić usuniętą wersję obiektu. "
-
-#: templates/reversion/recover_list.html:37
-msgid "There are no deleted objects to recover."
-msgstr "Nie ma żadnych usuniętych obiektów do przywrócenia."
-
-#: templates/reversion/revision_form.html:14
-msgid "History"
-msgstr "Historia"
-
-#: templates/reversion/revision_form.html:15
-#, python-format
-msgid "Revert %(verbose_name)s"
-msgstr "Przywróć %(verbose_name)s"
-
-#: templates/reversion/revision_form.html:28
-msgid "Press the save button below to revert to this version of the object."
-msgstr "Naciśnij przycisk Zapisz poniżej, by przywrócić tę wersję obiektu."
-
-#~ msgid "Recover %s"
-#~ msgstr "Przywróć %s"
-
View
BIN edtrac_project/django_reversion/reversion/locale/ru/LC_MESSAGES/django.mo
Binary file not shown.
View
118 edtrac_project/django_reversion/reversion/locale/ru/LC_MESSAGES/django.po
@@ -1,118 +0,0 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: reversion\n"
-"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-02-03 08:31+0100\n"
-"PO-Revision-Date: 2009-10-14 22:21+0300\n"
-"Last-Translator: Alexander Yakovlev <ayakovlev@rambler.ru>\n"
-"Language-Team: Russian <ru@li.org>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"X-Poedit-Language: Russian\n"
-"X-Poedit-Country: RUSSIAN FEDERATION\n"
-
-#: admin.py:122
-#: templates/reversion/change_list.html:8
-#: templates/reversion/recover_list.html:9
-#, python-format
-msgid "Recover deleted %(name)s"
-msgstr "Восстановить удаленный %(name)s"
-
-#: admin.py:155
-#, python-format
-msgid "Reverted to previous version, saved on %(datetime)s"
-msgstr "Возвращено к предыдущей версии, сохраненной %(datetime)s"
-
-#: admin.py:157
-#, python-format
-msgid "The %(model)s \"%(name)s\" was reverted successfully. You may edit it again below."
-msgstr "%(model)s \"%(name)s\" возвращен. Можете продолжить его редактирование."
-
-#: admin.py:227
-#, python-format
-msgid "Recover %s"
-msgstr "Восстановить %s"
-
-#: admin.py:243
-#, python-format
-msgid "Revert %(name)s"
-msgstr "Вернуть %(name)s"
-
-#: templates/reversion/change_list.html:11
-#, python-format
-msgid "Add %(name)s"
-msgstr "Добавить %(name)s"
-
-#: templates/reversion/object_history.html:8
-msgid "Choose a date from the list below to revert to a previous version of this object."
-msgstr "Выберите дату из списка, чтобы вернуть предыдущую версию этого объекта."
-
-#: templates/reversion/object_history.html:15
-#: templates/reversion/recover_list.html:21
-msgid "Date/time"
-msgstr "Дата/время"
-
-#: templates/reversion/object_history.html:16
-msgid "User"
-msgstr "Пользователь"
-
-#: templates/reversion/object_history.html:17
-msgid "Comment"
-msgstr "Комментарий"
-
-#: templates/reversion/object_history.html:23
-#: templates/reversion/recover_list.html:28
-msgid "DATETIME_FORMAT"
-msgstr "d.m.Y H:i"
-
-#: templates/reversion/object_history.html:31
-msgid "This object doesn't have a change history. It probably wasn't added via this admin site."
-msgstr "У этого объекта нет истории изменений. Возможно, он был добавлен не через администраторский сайт."
-
-#: templates/reversion/recover_form.html:14
-#: templates/reversion/recover_list.html:6
-#: templates/reversion/revision_form.html:14
-msgid "Home"
-msgstr "Начало"
-
-#: templates/reversion/recover_form.html:17
-#, python-format
-msgid "Recover deleted %(verbose_name)s"
-msgstr "Восстановить удаленный %(verbose_name)s"
-
-#: templates/reversion/recover_form.html:18
-#, python-format
-msgid "Recover %(name)s"
-msgstr "Восстановить %(name)s"
-
-#: templates/reversion/recover_form.html:24
-msgid "Press the save button below to recover this version of the object."
-msgstr "Нажмите кнопку \"Сохранить\" далее, чтобы восстановить эту версию объекта."
-
-#: templates/reversion/recover_list.html:15
-msgid "Choose a date from the list below to recover a deleted version of an object."
-msgstr "Выберите дату из списка, чтобы восстановить удаленную версию объекта."
-
-#: templates/reversion/recover_list.html:35
-msgid "There are no deleted objects to recover."
-msgstr "Не найдено удаленных объектов для восстановления."
-
-#: templates/reversion/revision_form.html:18
-msgid "History"
-msgstr "История"
-
-#: templates/reversion/revision_form.html:19
-#, python-format
-msgid "Revert %(verbose_name)s"
-msgstr "Вернуть %(verbose_name)s"
-
-#: templates/reversion/revision_form.html:32
-msgid "Press the save button below to revert to this version of the object."
-msgstr "Нажмите кнопку \"Сохранить\" далее, чтобы вернуть эту версию объекта."
-
View
1 edtrac_project/django_reversion/reversion/management/__init__.py
@@ -1 +0,0 @@
-"""Reversion management utilities."""
View
0 edtrac_project/django_reversion/reversion/management/commands/__init__.py
No changes.
View
109 edtrac_project/django_reversion/reversion/management/commands/createinitialrevisions.py
@@ -1,109 +0,0 @@
-from optparse import make_option
-
-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
-from django.utils.importlib import import_module
-from django.utils.datastructures import SortedDict
-from django.utils.encoding import smart_unicode
-
-from reversion import default_revision_manager
-from reversion.models import Version, has_int_pk
-
-
-class Command(BaseCommand):
- option_list = BaseCommand.option_list + (
- make_option("--comment",
- action="store",
- dest="comment",
- default=u"Initial version.",
- help='Specify the comment to add to the revisions. Defaults to "Initial version.".'),
- )
- args = '[appname, appname.ModelName, ...] [--comment="Initial version."]'
- help = "Creates initial revisions for a given app [and model]."
-
- def handle(self, *app_labels, **options):
- comment = options["comment"]
- verbosity = int(options.get("verbosity", 1))
- app_list = SortedDict()
- # if no apps given, use all installed.
- if len(app_labels) == 0:
- for app in models.get_apps ():
- if not app in app_list.keys():
- app_list[app] = []
- for model_class in models.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)
- except ImproperlyConfigured:
- raise CommandError("Unknown application: %s" % app_label)
-
- model_class = models.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.keys():
- if app_list[app] and model_class not in app_list[app]:
- app_list[app].append(model_class)
- else:
- app_list[app] = [model_class]
- except ValueError:
- # This is just an app - no model qualifier.
- app_label = label
- try:
- app = models.get_app(app_label)
- if not app in app_list.keys():
- app_list[app] = []
- for model_class in models.get_models(app):
- if not model_class in app_list[app]:
- app_list[app].append(model_class)
- except ImproperlyConfigured:
- raise CommandError("Unknown application: %s" % app_label)
- # Create revisions.
- for app, model_classes in app_list.items():
- for model_class in model_classes:
- self.create_initial_revisions(app, model_class, comment, verbosity)
-
- def create_initial_revisions(self, app, model_class, comment, verbosity=2, **kwargs):
- """Creates the set of initial revisions for the given model."""
- # Import the relevant admin module.
- try:
- import_module("%s.admin" % app.__name__.rsplit(".", 1)[0])
- except ImportError:
- pass
- # Check all models for empty revisions.
- if default_revision_manager.is_registered(model_class):
- created_count = 0
- content_type = ContentType.objects.get_for_model(model_class)
- versioned_pk_queryset = Version.objects.filter(content_type=content_type).all()
- live_objs = model_class._default_manager.all()
- if has_int_pk(model_class):
- # We can do this as a fast database join!
- live_objs = live_objs.exclude(
- pk__in = versioned_pk_queryset.values_list("object_id_int", flat=True)
- )
- else:
- # This join has to be done as two separate queries.
- live_objs = live_objs.exclude(
- pk__in = list(versioned_pk_queryset.values_list("object_id", flat=True).iterator())
- )
- # Save all the versions.
- for obj in live_objs:
- try:
- default_revision_manager.save_revision((obj,), comment=comment)
- except:
- print "ERROR: Could not save initial version for %s %s." % (model_class.__name__, obj.pk)
- raise
- created_count += 1
- # Print out a message, if feeling verbose.
- if verbosity >= 2:
- print u"Created %s initial revision(s) for model %s." % (created_count, smart_unicode(model_class._meta.verbose_name))
- else:
- if verbosity >= 2:
- print u"Model %s is not registered." % (smart_unicode(model_class._meta.verbose_name))
View
195 edtrac_project/django_reversion/reversion/management/commands/deleterevisions.py
@@ -1,195 +0,0 @@
-import datetime, operator, sys
-from optparse import make_option
-
-from django.core.management.base import BaseCommand
-from django.core.management.base import CommandError
-from django.db.models import Q, Count
-from django.contrib.contenttypes.models import ContentType
-
-from reversion.models import Revision, Version
-
-
-class Command(BaseCommand):
- option_list = BaseCommand.option_list + (
- make_option("--date", "-t",
- dest="date",
- help="Delete only revisions older then the specify date. The date should be a valid date given in the ISO format (YYYY-MM-DD)"),
- make_option("--days", "-d",
- dest="days",
- default=0,
- type="int",
- help="Delete only revisions older then the specify number of days."),
- make_option("--keep-revision", "-k",
- dest="keep",
- default=0,
- type="int",
- help="Keep the specified number of revisions (most recent) for each object."),
- make_option("--force", "-f",
- action="store_true",
- dest="force",
- default=False,
- help="Force the deletion of revisions even if an other app/model is involved"),
- make_option("--no-confirmation", "-c",
- action="store_false",
- dest="confirmation",
- default=True,
- help="Disable the confirmation before deleting revisions"),
- )
- args = "[appname, appname.ModelName, ...] [--date=YYYY-MM-DD | days=0] [--keep=0] [--force] [--no-confirmation]"
- help = """Deletes revisions for a given app [and model] and/or before a specified delay or date.
-
-If an app or a model is specified, revisions that have an other app/model involved will not be deleted. Use --force to avoid that.
-
-You can specify only apps/models or only delay or date or only a nuber of revision to keep or use all possible combinations of these options.
-
-Examples:
-
- deleterevisions myapp
-
- That will delete every revisions of myapp (except if there's an other app involved in the revision)
-
- deleterevisions --date=2010-11-01
-
- That will delete every revision created before November 1, 2010 for all apps.
-
- deleterevisions myapp.mymodel --days=365 --force
-
- That will delete every revision of myapp.model that are older then 365 days, even if there's revisions involving other apps and/or models.
-
- deleterevisions myapp.mymodel --keep=10
-
- That will delete only revisions of myapp.model if there's more then 10 revisions for an object, keeping the 10 most recent revisons.
-"""
-
- def handle(self, *app_labels, **options):
- days = options["days"]
- keep = options["keep"]
- force = options["force"]
- confirmation = options["confirmation"]
- # I don't know why verbosity is not already an int in Django?
- try:
- verbosity = int(options["verbosity"])
- except ValueError:
- raise CommandError("option -v: invalid choice: '%s' (choose from '0', '1', '2')" % options["verbosity"])
-
- date = None
-
- # Validating arguments
- if options["date"]:
- if days:
- raise CommandError("You cannot use --date and --days at the same time. They are exclusive.")
-
- try:
- date = datetime.datetime.strptime(options["date"], "%Y-%m-%d").date()
- except ValueError:
- raise CommandError("The date you give (%s) is not a valid date. The date should be in the ISO format (YYYY-MM-DD)." % options["date"])
-
- # Find the date from the days arguments.
- elif days:
- date = datetime.datetime.now() - datetime.timedelta(days)
-
- # Build the queries
- revision_query = Revision.objects.all()
-
- if date:
- revision_query = revision_query.filter(date_created__lt=date)
-
- if app_labels:
- app_list = set()
- mod_list = set()
- for label in app_labels:
- try:
- app_label, model_label = label.split(".")
- mod_list.add((app_label, model_label))
- except ValueError:
- # This is just an app, no model qualifier.
- app_list.add(label)
-
- # Remove models that their app is already in app_list
- for app, model in mod_list.copy():
- if app in app_list:
- mod_list.remove((app, model))
-
- # Build apps/models subqueries
- subqueries = []
- if app_list:
- subqueries.append(Q(app_label__in=app_list))
- if mod_list:
- subqueries.extend([Q(app_label=app, model=model) for app, model in mod_list])
- subqueries = reduce(operator.or_, subqueries)
-
- if force:
- models = ContentType.objects.filter(subqueries)
- revision_query = revision_query.filter(version__content_type__in=models)
- else:
- models = ContentType.objects.exclude(subqueries)
- revision_query = revision_query.exclude(version__content_type__in=models)
-
- if keep:
- objs = Version.objects.all()
-
- # If app is specified, to speed up the loop on theses objects,
- # get only the specified subset.
- if app_labels:
- if force:
- objs = objs.filter(content_type__in=models)
- else:
- objs = objs.exclude(content_type__in=models)
-
- # Get all the objects that have more then the maximum revisions
- objs = objs.values("object_id", "content_type_id").annotate(total_ver=Count("object_id")).filter(total_ver__gt=keep)
-
- revisions_not_keeped = set()
-
- # Get all ids of the oldest revisions minus the max allowed
- # revisions for all objects.
- # Was not able to avoid this loop...
- for obj in objs:
- revisions_not_keeped.update(list(Version.objects.filter(content_type__id=obj["content_type_id"], object_id=obj["object_id"]).order_by("-revision__date_created").values_list("revision_id", flat=True)[keep:]))
-
- revision_query = revision_query.filter(pk__in=revisions_not_keeped)
-
-
- # Prepare message if verbose
- if verbosity > 0:
- if not date and not app_labels and not keep:
- print "All revisions will be deleted for all models."
- else:
- date_msg = ""
- if date:
- date_msg = " older than %s" % date.isoformat()
- models_msg = " "
- if app_labels:
- force_msg = ""
- if not force:
- force_msg = " only"
- models_msg = " having%s theses apps and models:\n- %s\n" % (force_msg, "\n- ".join(sorted(app_list.union(["%s.%s" % (app, model) for app, model in mod_list])),))
- if date:
- models_msg = " and" + models_msg
- keep_msg = ""
- if keep:
- keep_msg = " keeping the %s most recent revisions of each object" % keep
-
- revision_count = revision_query.count()
- if revision_count:
- version_query = Version.objects.all()
- if date or app_labels or keep:
- version_query = version_query.filter(revision__in=revision_query)
- print "%s revision(s)%s%swill be deleted%s.\n%s model version(s) will be deleted." % (revision_count, date_msg, models_msg, keep_msg, version_query.count())
- else:
- print "No revision%s%sto delete%s.\nDone" % (date_msg, models_msg, keep_msg)
- sys.exit()
-
-
- # Ask confirmation
- if confirmation:
- choice = raw_input("Are you sure you want to delete theses revisions? [y|N] ")
- if choice.lower() != "y":
- print "Aborting revision deletion."
- sys.exit()
-
-
- # Delete versions and revisions
- print "Deleting revisions..."
- revision_query.delete()
- print "Done"
View
34 edtrac_project/django_reversion/reversion/middleware.py
@@ -1,34 +0,0 @@
-"""Middleware used by Reversion."""
-
-from reversion.revisions import revision_context_manager
-
-
-REVISION_MIDDLEWARE_FLAG = "reversion.revision_middleware_active"
-
-
-class RevisionMiddleware(object):
-
- """Wraps the entire request in a revision."""
-
- def process_request(self, request):
- """Starts a new revision."""
- request.META[(REVISION_MIDDLEWARE_FLAG, self)] = True
- revision_context_manager.start()
- if hasattr(request, "user") and request.user.is_authenticated():
- revision_context_manager.set_user(request.user)
-
- def _close_revision(self, request):
- """Closes the revision."""
- if request.META.get((REVISION_MIDDLEWARE_FLAG, self), False):
- del request.META[(REVISION_MIDDLEWARE_FLAG, self)]
- revision_context_manager.end()
-
- def process_response(self, request, response):
- """Closes the revision."""
- self._close_revision(request)
- return response
-
- def process_exception(self, request, exception):
- """Closes the revision."""
- revision_context_manager.invalidate()
- self._close_revision(request)
View
97 edtrac_project/django_reversion/reversion/migrations/0001_initial.py
@@ -1,97 +0,0 @@
-# encoding: utf-8
-import datetime
-from south.db import db
-from south.v2 import SchemaMigration
-from django.db import models
-
-
-class Migration(SchemaMigration):
-
- def forwards(self, orm):
-
- # Adding model 'Revision'
- db.create_table('reversion_revision', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('date_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
- ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, blank=True)),
- ('comment', self.gf('django.db.models.fields.TextField')(blank=True)),
- ))
- db.send_create_signal('reversion', ['Revision'])
-
- # Adding model 'Version'
- db.create_table('reversion_version', (
- ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
- ('revision', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['reversion.Revision'])),
- ('object_id', self.gf('django.db.models.fields.TextField')()),
- ('content_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['contenttypes.ContentType'])),
- ('format', self.gf('django.db.models.fields.CharField')(max_length=255)),
- ('serialized_data', self.gf('django.db.models.fields.TextField')()),
- ('object_repr', self.gf('django.db.models.fields.TextField')()),
- ))
- db.send_create_signal('reversion', ['Version'])
-
- def backwards(self, orm):
-
- # Deleting model 'Revision'
- db.delete_table('reversion_revision')
-
- # Deleting model 'Version'
- db.delete_table('reversion_version')
-
- models = {
- 'auth.group': {
- 'Meta': {'object_name': 'Group'},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
- 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
- },
- 'auth.permission': {
- 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
- 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
- },
- 'auth.user': {
- 'Meta': {'object_name': 'User'},
- 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
- 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
- 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
- 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
- },
- 'contenttypes.contenttype': {
- 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
- 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
- },
- 'reversion.revision': {
- 'Meta': {'object_name': 'Revision'},
- 'comment': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'})
- },
- 'reversion.version': {
- 'Meta': {'object_name': 'Version'},
- 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
- 'format': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'object_id': ('django.db.models.fields.TextField', [], {}),
- 'object_repr': ('django.db.models.fields.TextField', [], {}),
- 'revision': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['reversion.Revision']"}),
- 'serialized_data': ('django.db.models.fields.TextField', [], {})
- }
- }
-
- complete_apps = ['reversion']
View
79 edtrac_project/django_reversion/reversion/migrations/0002_auto__add_field_version_type.py
@@ -1,79 +0,0 @@
-# encoding: utf-8
-import datetime
-from south.db import db
-from south.v2 import SchemaMigration
-from django.db import models
-
-from reversion.models import VERSION_CHANGE
-
-
-class Migration(SchemaMigration):
-
- def forwards(self, orm):
-
- # Adding field 'Version.type'
- db.add_column('reversion_version', 'type', self.gf('django.db.models.fields.PositiveSmallIntegerField')(default=VERSION_CHANGE, db_index=True), keep_default=False)
-
- def backwards(self, orm):
-
- # Deleting field 'Version.type'
- db.delete_column('reversion_version', 'type')
-
- models = {
- 'auth.group': {
- 'Meta': {'object_name': 'Group'},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
- 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
- },
- 'auth.permission': {
- 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
- 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
- },
- 'auth.user': {
- 'Meta': {'object_name': 'User'},
- 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
- 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
- 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
- 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
- },
- 'contenttypes.contenttype': {
- 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
- 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
- },
- 'reversion.revision': {
- 'Meta': {'object_name': 'Revision'},
- 'comment': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
- 'date_created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'})
- },
- 'reversion.version': {
- 'Meta': {'object_name': 'Version'},
- 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
- 'format': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'object_id': ('django.db.models.fields.TextField', [], {}),
- 'object_repr': ('django.db.models.fields.TextField', [], {}),
- 'revision': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['reversion.Revision']"}),
- 'serialized_data': ('django.db.models.fields.TextField', [], {}),
- 'type': ('django.db.models.fields.PositiveSmallIntegerField', [], {'db_index': 'True'})
- }