More document grouping rename updates

This commit is contained in:
Roberto Rosario
2011-11-18 23:29:19 -04:00
parent 9f4112187e
commit 7a32eccc19
4 changed files with 12 additions and 12 deletions

View File

@@ -105,17 +105,17 @@ class SmartLinkImageWidget(forms.widgets.Widget):
class SmartLinkInstanceForm(forms.Form):
def __init__(self, *args, **kwargs):
groups = kwargs.pop('groups', None)
smart_link_instances = kwargs.pop('smart_link_instances', None)
links = kwargs.pop('links', None)
current_document = kwargs.pop('current_document', None)
super(SmartLinkInstanceForm, self).__init__(*args, **kwargs)
for group, data in groups.items():
self.fields['preview-%s' % group] = forms.CharField(
for smart_link_instance, data in smart_link_instances.items():
self.fields['preview-%s' % smart_link_instance] = forms.CharField(
widget=SmartLinkImageWidget(),
label=u'%s (%d)' % (unicode(data['title']), len(data['documents'])),
required=False,
initial={
'group': group,
'group': smart_link_instance,
'group_data': data['documents'],
'current_document': current_document,
'links': links

View File

@@ -7,7 +7,7 @@ from documents.models import Document
from grouping.literals import INCLUSION_AND, INCLUSION_OR
class DocumentGroupManager(models.Manager):
class SmartLinkManager(models.Manager):
def get_groups_for(self, document, group_obj=None):
errors = []
document_groups = {}

View File

@@ -1,7 +1,7 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from grouping.managers import DocumentGroupManager
from grouping.managers import SmartLinkManager
from grouping.literals import OPERATOR_CHOICES, INCLUSION_AND, \
INCLUSION_CHOICES
@@ -11,7 +11,7 @@ class DocumentGroup(models.Model):
dynamic_title = models.CharField(blank=True, max_length=96, verbose_name=_(u'dynamic title'), help_text=_(u'This expression will be evaluated against the current selected document. The document metadata is available as variables `metadata` and document properties under the variable `document`.'))
enabled = models.BooleanField(default=True, verbose_name=_(u'enabled'))
objects = DocumentGroupManager()
objects = SmartLinkManager()
def __unicode__(self):
return self.title

View File

@@ -59,7 +59,7 @@ def smart_link_instances_for_document(request, document_id):
subtemplates_list = []
document = get_object_or_404(Document, pk=document_id)
smart_links, errors = DocumentGroup.objects.get_groups_for(document)
smart_link_instances, errors = DocumentGroup.objects.get_groups_for(document)
if (request.user.is_staff or request.user.is_superuser) and errors:
for error in errors:
messages.warning(request, _(u'Smart link query error: %s' % error))
@@ -67,15 +67,15 @@ def smart_link_instances_for_document(request, document_id):
if not SHOW_EMPTY_GROUPS:
#If GROUP_SHOW_EMPTY is False, remove empty groups from
#dictionary
document_groups = dict([(group, data) for group, data in document_groups.items() if data['documents']])
smart_link_instances = dict([(group, data) for group, data in smart_link_instances.items() if data['documents']])
if smart_links:
if smart_link_instances:
subtemplates_list = [{
'name': 'generic_form_subtemplate.html',
'context': {
'title': _(u'smart links (%s)') % len(smart_links.keys()),
'title': _(u'smart links (%s)') % len(smart_link_instances.keys()),
'form': SmartLinkInstanceForm(
groups=smart_links, current_document=document,
smart_link_instances=smart_link_instances, current_document=document,
links=[smart_link_instance_view_link]
),
'form_action': reverse('smart_link_action'),