Add from __future__ import unicode_literals, issue #37
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from acls.api import class_permissions
|
||||
from acls.permissions import ACLS_EDIT_ACL, ACLS_VIEW_ACL
|
||||
@@ -7,17 +7,18 @@ from navigation.api import register_links
|
||||
from project_setup.api import register_setup
|
||||
|
||||
from .classes import ResolvedSmartLink
|
||||
from .links import (smart_link_acl_list,
|
||||
smart_link_create, smart_link_condition_create,
|
||||
smart_link_condition_delete, smart_link_condition_edit,
|
||||
smart_link_condition_list, smart_link_delete,
|
||||
smart_link_document_types, smart_link_edit,
|
||||
smart_link_instance_view, smart_link_instances_for_document, smart_link_list,
|
||||
smart_link_setup)
|
||||
from .links import (
|
||||
smart_link_acl_list, smart_link_create, smart_link_condition_create,
|
||||
smart_link_condition_delete, smart_link_condition_edit,
|
||||
smart_link_condition_list, smart_link_delete, smart_link_document_types,
|
||||
smart_link_edit, smart_link_instance_view,
|
||||
smart_link_instances_for_document, smart_link_list, smart_link_setup
|
||||
)
|
||||
from .models import SmartLink, SmartLinkCondition
|
||||
from .permissions import (PERMISSION_SMART_LINK_DELETE,
|
||||
PERMISSION_SMART_LINK_EDIT,
|
||||
PERMISSION_SMART_LINK_VIEW)
|
||||
from .permissions import (
|
||||
PERMISSION_SMART_LINK_DELETE, PERMISSION_SMART_LINK_EDIT,
|
||||
PERMISSION_SMART_LINK_VIEW
|
||||
)
|
||||
|
||||
register_links(Document, [smart_link_instances_for_document], menu_name='form_header')
|
||||
register_links(SmartLink, [smart_link_edit, smart_link_document_types, smart_link_condition_list, smart_link_acl_list, smart_link_delete])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
ResolvedSmartLink = namedtuple('ResolvedSmartLink', ['smart_link', 'queryset'])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from acls.permissions import ACLS_VIEW_ACL
|
||||
from documents.permissions import PERMISSION_DOCUMENT_VIEW
|
||||
|
||||
from .permissions import (PERMISSION_SMART_LINK_CREATE,
|
||||
PERMISSION_SMART_LINK_DELETE,
|
||||
PERMISSION_SMART_LINK_EDIT,
|
||||
PERMISSION_SMART_LINK_VIEW)
|
||||
from .permissions import (
|
||||
PERMISSION_SMART_LINK_CREATE, PERMISSION_SMART_LINK_DELETE,
|
||||
PERMISSION_SMART_LINK_EDIT, PERMISSION_SMART_LINK_VIEW
|
||||
)
|
||||
|
||||
smart_link_setup = {'text': _(u'Smart links'), 'view': 'linking:smart_link_list', 'icon': 'link.png', 'permissions': [PERMISSION_SMART_LINK_CREATE]}
|
||||
smart_link_list = {'text': _(u'Smart links'), 'view': 'linking:smart_link_list', 'famfam': 'link', 'permissions': [PERMISSION_SMART_LINK_CREATE]}
|
||||
smart_link_create = {'text': _(u'Create new smart link'), 'view': 'linking:smart_link_create', 'famfam': 'link_add', 'permissions': [PERMISSION_SMART_LINK_CREATE]}
|
||||
smart_link_edit = {'text': _(u'Edit'), 'view': 'linking:smart_link_edit', 'args': 'object.pk', 'famfam': 'link_edit', 'permissions': [PERMISSION_SMART_LINK_EDIT]}
|
||||
smart_link_delete = {'text': _(u'Delete'), 'view': 'linking:smart_link_delete', 'args': 'object.pk', 'famfam': 'link_delete', 'permissions': [PERMISSION_SMART_LINK_DELETE]}
|
||||
smart_link_setup = {'text': _('Smart links'), 'view': 'linking:smart_link_list', 'icon': 'link.png', 'permissions': [PERMISSION_SMART_LINK_CREATE]}
|
||||
smart_link_list = {'text': _('Smart links'), 'view': 'linking:smart_link_list', 'famfam': 'link', 'permissions': [PERMISSION_SMART_LINK_CREATE]}
|
||||
smart_link_create = {'text': _('Create new smart link'), 'view': 'linking:smart_link_create', 'famfam': 'link_add', 'permissions': [PERMISSION_SMART_LINK_CREATE]}
|
||||
smart_link_edit = {'text': _('Edit'), 'view': 'linking:smart_link_edit', 'args': 'object.pk', 'famfam': 'link_edit', 'permissions': [PERMISSION_SMART_LINK_EDIT]}
|
||||
smart_link_delete = {'text': _('Delete'), 'view': 'linking:smart_link_delete', 'args': 'object.pk', 'famfam': 'link_delete', 'permissions': [PERMISSION_SMART_LINK_DELETE]}
|
||||
smart_link_document_types = {'text': _('Document types'), 'view': 'linking:smart_link_document_types', 'args': 'object.pk', 'famfam': 'layout', 'permissions': [PERMISSION_SMART_LINK_EDIT]}
|
||||
|
||||
smart_link_instances_for_document = {'text': _(u'Smart links'), 'view': 'linking:smart_link_instances_for_document', 'args': 'object.pk', 'famfam': 'page_link', 'permissions': [PERMISSION_DOCUMENT_VIEW]}
|
||||
smart_link_instances_for_document = {'text': _('Smart links'), 'view': 'linking:smart_link_instances_for_document', 'args': 'object.pk', 'famfam': 'page_link', 'permissions': [PERMISSION_DOCUMENT_VIEW]}
|
||||
smart_link_instance_view = {'text': _('Documents'), 'view': 'linking:smart_link_instance_view', 'args': ['document.pk', 'object.smart_link.pk'], 'famfam': 'layout', 'page': [PERMISSION_SMART_LINK_VIEW]}
|
||||
|
||||
smart_link_condition_list = {'text': _(u'Conditions'), 'view': 'linking:smart_link_condition_list', 'args': 'object.pk', 'famfam': 'cog', 'permissions': [PERMISSION_SMART_LINK_EDIT]}
|
||||
smart_link_condition_create = {'text': _(u'Create condition'), 'view': 'linking:smart_link_condition_create', 'args': 'object.pk', 'famfam': 'cog_add', 'permissions': [PERMISSION_SMART_LINK_EDIT]}
|
||||
smart_link_condition_edit = {'text': _(u'Edit'), 'view': 'linking:smart_link_condition_edit', 'args': 'condition.pk', 'famfam': 'cog_edit', 'permissions': [PERMISSION_SMART_LINK_EDIT]}
|
||||
smart_link_condition_delete = {'text': _(u'Delete'), 'view': 'linking:smart_link_condition_delete', 'args': 'condition.pk', 'famfam': 'cog_delete', 'permissions': [PERMISSION_SMART_LINK_EDIT]}
|
||||
smart_link_condition_list = {'text': _('Conditions'), 'view': 'linking:smart_link_condition_list', 'args': 'object.pk', 'famfam': 'cog', 'permissions': [PERMISSION_SMART_LINK_EDIT]}
|
||||
smart_link_condition_create = {'text': _('Create condition'), 'view': 'linking:smart_link_condition_create', 'args': 'object.pk', 'famfam': 'cog_add', 'permissions': [PERMISSION_SMART_LINK_EDIT]}
|
||||
smart_link_condition_edit = {'text': _('Edit'), 'view': 'linking:smart_link_condition_edit', 'args': 'condition.pk', 'famfam': 'cog_edit', 'permissions': [PERMISSION_SMART_LINK_EDIT]}
|
||||
smart_link_condition_delete = {'text': _('Delete'), 'view': 'linking:smart_link_condition_delete', 'args': 'condition.pk', 'famfam': 'cog_delete', 'permissions': [PERMISSION_SMART_LINK_EDIT]}
|
||||
|
||||
smart_link_acl_list = {'text': _(u'ACLs'), 'view': 'linking:smart_link_acl_list', 'args': 'object.pk', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]}
|
||||
smart_link_acl_list = {'text': _('ACLs'), 'view': 'linking:smart_link_acl_list', 'args': 'object.pk', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]}
|
||||
|
||||
@@ -1,27 +1,29 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
INCLUSION_AND = u'&'
|
||||
INCLUSION_OR = u'|'
|
||||
INCLUSION_AND = '&'
|
||||
INCLUSION_OR = '|'
|
||||
|
||||
INCLUSION_CHOICES = (
|
||||
(INCLUSION_AND, _(u'and')),
|
||||
(INCLUSION_OR, _(u'or')),
|
||||
(INCLUSION_AND, _('and')),
|
||||
(INCLUSION_OR, _('or')),
|
||||
)
|
||||
|
||||
OPERATOR_CHOICES = (
|
||||
(u'exact', _(u'is equal to')),
|
||||
(u'iexact', _(u'is equal to (case insensitive)')),
|
||||
(u'contains', _(u'contains')),
|
||||
(u'icontains', _(u'contains (case insensitive)')),
|
||||
(u'in', _(u'is in')),
|
||||
(u'gt', _(u'is greater than')),
|
||||
(u'gte', _(u'is greater than or equal to')),
|
||||
(u'lt', _(u'is less than')),
|
||||
(u'lte', _(u'is less than or equal to')),
|
||||
(u'startswith', _(u'starts with')),
|
||||
(u'istartswith', _(u'starts with (case insensitive)')),
|
||||
(u'endswith', _(u'ends with')),
|
||||
(u'iendswith', _(u'ends with (case insensitive)')),
|
||||
(u'regex', _(u'is in regular expression')),
|
||||
(u'iregex', _(u'is in regular expression (case insensitive)')),
|
||||
('exact', _('is equal to')),
|
||||
('iexact', _('is equal to (case insensitive)')),
|
||||
('contains', _('contains')),
|
||||
('icontains', _('contains (case insensitive)')),
|
||||
('in', _('is in')),
|
||||
('gt', _('is greater than')),
|
||||
('gte', _('is greater than or equal to')),
|
||||
('lt', _('is less than')),
|
||||
('lte', _('is less than or equal to')),
|
||||
('startswith', _('starts with')),
|
||||
('istartswith', _('starts with (case insensitive)')),
|
||||
('endswith', _('ends with')),
|
||||
('iendswith', _('ends with (case insensitive)')),
|
||||
('regex', _('is in regular expression')),
|
||||
('iregex', _('is in regular expression (case insensitive)')),
|
||||
)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.db import models
|
||||
|
||||
from .classes import ResolvedSmartLink
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
@@ -13,10 +13,10 @@ from .managers import SmartLinkManager
|
||||
|
||||
|
||||
class SmartLink(models.Model):
|
||||
title = models.CharField(max_length=96, verbose_name=_(u'Title'))
|
||||
dynamic_title = models.CharField(blank=True, max_length=96, verbose_name=_(u'Dynamic title'), help_text=ugettext(u'This expression will be evaluated against the current selected document.'))
|
||||
enabled = models.BooleanField(default=True, verbose_name=_(u'Enabled'))
|
||||
document_types = models.ManyToManyField(DocumentType, verbose_name=_(u'Document types'))
|
||||
title = models.CharField(max_length=96, verbose_name=_('Title'))
|
||||
dynamic_title = models.CharField(blank=True, max_length=96, verbose_name=_('Dynamic title'), help_text=ugettext('This expression will be evaluated against the current selected document.'))
|
||||
enabled = models.BooleanField(default=True, verbose_name=_('Enabled'))
|
||||
document_types = models.ManyToManyField(DocumentType, verbose_name=_('Document types'))
|
||||
|
||||
objects = SmartLinkManager()
|
||||
|
||||
@@ -56,22 +56,22 @@ class SmartLink(models.Model):
|
||||
return Document.objects.none()
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'Smart link')
|
||||
verbose_name_plural = _(u'Smart links')
|
||||
verbose_name = _('Smart link')
|
||||
verbose_name_plural = _('Smart links')
|
||||
|
||||
|
||||
class SmartLinkCondition(models.Model):
|
||||
smart_link = models.ForeignKey(SmartLink, related_name='conditions', verbose_name=_(u'Smart link'))
|
||||
inclusion = models.CharField(default=INCLUSION_AND, max_length=16, choices=INCLUSION_CHOICES, help_text=_(u'The inclusion is ignored for the first item.'))
|
||||
foreign_document_data = models.CharField(max_length=128, verbose_name=_(u'Foreign document attribute'), help_text=_(u'This represents the metadata of all other documents.'))
|
||||
smart_link = models.ForeignKey(SmartLink, related_name='conditions', verbose_name=_('Smart link'))
|
||||
inclusion = models.CharField(default=INCLUSION_AND, max_length=16, choices=INCLUSION_CHOICES, help_text=_('The inclusion is ignored for the first item.'))
|
||||
foreign_document_data = models.CharField(max_length=128, verbose_name=_('Foreign document attribute'), help_text=_('This represents the metadata of all other documents.'))
|
||||
operator = models.CharField(max_length=16, choices=OPERATOR_CHOICES)
|
||||
expression = models.TextField(verbose_name=_(u'Expression'), help_text=ugettext(u'This expression will be evaluated against the current document.'))
|
||||
negated = models.BooleanField(default=False, verbose_name=_(u'Negated'), help_text=_(u'Inverts the logic of the operator.'))
|
||||
enabled = models.BooleanField(default=True, verbose_name=_(u'Enabled'))
|
||||
expression = models.TextField(verbose_name=_('Expression'), help_text=ugettext('This expression will be evaluated against the current document.'))
|
||||
negated = models.BooleanField(default=False, verbose_name=_('Negated'), help_text=_('Inverts the logic of the operator.'))
|
||||
enabled = models.BooleanField(default=True, verbose_name=_('Enabled'))
|
||||
|
||||
def __unicode__(self):
|
||||
return u'%s foreign %s %s %s %s' % (self.get_inclusion_display(), self.foreign_document_data, _(u'not') if self.negated else u'', self.get_operator_display(), self.expression)
|
||||
return '%s foreign %s %s %s %s' % (self.get_inclusion_display(), self.foreign_document_data, _('not') if self.negated else '', self.get_operator_display(), self.expression)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'Link condition')
|
||||
verbose_name_plural = _(u'Link conditions')
|
||||
verbose_name = _('Link condition')
|
||||
verbose_name_plural = _('Link conditions')
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from permissions.models import PermissionNamespace, Permission
|
||||
|
||||
linking_namespace = PermissionNamespace('linking', _(u'Smart links'))
|
||||
linking_namespace = PermissionNamespace('linking', _('Smart links'))
|
||||
|
||||
PERMISSION_SMART_LINK_VIEW = Permission.objects.register(linking_namespace, 'smart_link_view', _(u'View existing smart links'))
|
||||
PERMISSION_SMART_LINK_CREATE = Permission.objects.register(linking_namespace, 'smart_link_create', _(u'Create new smart links'))
|
||||
PERMISSION_SMART_LINK_DELETE = Permission.objects.register(linking_namespace, 'smart_link_delete', _(u'Delete smart links'))
|
||||
PERMISSION_SMART_LINK_EDIT = Permission.objects.register(linking_namespace, 'smart_link_edit', _(u'Edit smart links'))
|
||||
PERMISSION_SMART_LINK_VIEW = Permission.objects.register(linking_namespace, 'smart_link_view', _('View existing smart links'))
|
||||
PERMISSION_SMART_LINK_CREATE = Permission.objects.register(linking_namespace, 'smart_link_create', _('Create new smart links'))
|
||||
PERMISSION_SMART_LINK_DELETE = Permission.objects.register(linking_namespace, 'smart_link_delete', _('Delete smart links'))
|
||||
PERMISSION_SMART_LINK_EDIT = Permission.objects.register(linking_namespace, 'smart_link_edit', _('Edit smart links'))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf.urls import patterns, url
|
||||
|
||||
urlpatterns = patterns('linking.views',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
@@ -22,10 +22,10 @@ from permissions.models import Permission
|
||||
|
||||
from .forms import SmartLinkConditionForm, SmartLinkForm
|
||||
from .models import SmartLink, SmartLinkCondition
|
||||
from .permissions import (PERMISSION_SMART_LINK_CREATE,
|
||||
PERMISSION_SMART_LINK_DELETE,
|
||||
PERMISSION_SMART_LINK_EDIT,
|
||||
PERMISSION_SMART_LINK_VIEW)
|
||||
from .permissions import (
|
||||
PERMISSION_SMART_LINK_CREATE, PERMISSION_SMART_LINK_DELETE,
|
||||
PERMISSION_SMART_LINK_EDIT, PERMISSION_SMART_LINK_VIEW
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -45,11 +45,11 @@ def smart_link_instance_view(request, document_id, smart_link_pk):
|
||||
object_list = []
|
||||
|
||||
if request.user.is_staff or request.user.is_superuser:
|
||||
messages.error(request, _(u'Smart link query error: %s' % exception))
|
||||
messages.error(request, _('Smart link query error: %s' % exception))
|
||||
|
||||
return document_list(
|
||||
request,
|
||||
title=_(u'Documents in smart link: %s') % smart_link.get_dynamic_title(document),
|
||||
title=_('Documents in smart link: %s') % smart_link.get_dynamic_title(document),
|
||||
object_list=object_list,
|
||||
extra_context={
|
||||
'object': document
|
||||
@@ -64,7 +64,7 @@ def smart_link_instances_for_document(request, document_id):
|
||||
queryset = SmartLink.objects.get_for(document)
|
||||
except Exception as exception:
|
||||
queryset = []
|
||||
messages.error(request, _(u'Error calculating smart link for: %(document)s; %(exception)s.') %
|
||||
messages.error(request, _('Error calculating smart link for: %(document)s; %(exception)s.') %
|
||||
{'document': document, 'exception': exception}
|
||||
)
|
||||
|
||||
@@ -79,7 +79,7 @@ def smart_link_instances_for_document(request, document_id):
|
||||
'document': document,
|
||||
'object': document,
|
||||
'object_list': smart_links,
|
||||
'title': _(u'Document smart links'),
|
||||
'title': _('Document smart links'),
|
||||
'extra_columns': [
|
||||
{'name': _('Indentifier'), 'attribute': encapsulate(lambda resolved_smart_link: resolved_smart_link.smart_link.get_dynamic_title(document))},
|
||||
{'name': _('Documents'), 'attribute': encapsulate(lambda resolved_smart_link: resolved_smart_link.queryset.count())}
|
||||
@@ -109,11 +109,11 @@ def smart_link_list(request):
|
||||
qs = AccessEntry.objects.filter_objects_by_access(PERMISSION_SMART_LINK_VIEW, request.user, qs)
|
||||
|
||||
return render_to_response('main/generic_list.html', {
|
||||
'title': _(u'Smart links'),
|
||||
'title': _('Smart links'),
|
||||
'object_list': qs,
|
||||
'extra_columns': [
|
||||
{'name': _(u'Dynamic title'), 'attribute': 'dynamic_title'},
|
||||
{'name': _(u'Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))},
|
||||
{'name': _('Dynamic title'), 'attribute': 'dynamic_title'},
|
||||
{'name': _('Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))},
|
||||
],
|
||||
'hide_link': True,
|
||||
'list_object_variable_name': 'smart_link',
|
||||
@@ -129,14 +129,14 @@ def smart_link_create(request):
|
||||
if form.is_valid():
|
||||
document_group = form.save()
|
||||
apply_default_acls(document_group, request.user)
|
||||
messages.success(request, _(u'Smart link: %s created successfully.') % document_group)
|
||||
messages.success(request, _('Smart link: %s created successfully.') % document_group)
|
||||
return HttpResponseRedirect(reverse('linking:smart_link_list'))
|
||||
else:
|
||||
form = SmartLinkForm()
|
||||
|
||||
return render_to_response('main/generic_form.html', {
|
||||
'form': form,
|
||||
'title': _(u'Create new smart link')
|
||||
'title': _('Create new smart link')
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ def smart_link_edit(request, smart_link_pk):
|
||||
form = SmartLinkForm(request.POST, instance=smart_link)
|
||||
if form.is_valid():
|
||||
smart_link = form.save()
|
||||
messages.success(request, _(u'Smart link: %s edited successfully.') % smart_link)
|
||||
messages.success(request, _('Smart link: %s edited successfully.') % smart_link)
|
||||
return HttpResponseRedirect(reverse('linking:smart_link_list'))
|
||||
else:
|
||||
form = SmartLinkForm(instance=smart_link)
|
||||
@@ -160,7 +160,7 @@ def smart_link_edit(request, smart_link_pk):
|
||||
return render_to_response('main/generic_form.html', {
|
||||
'object': smart_link,
|
||||
'form': form,
|
||||
'title': _(u'Edit smart link: %s') % smart_link
|
||||
'title': _('Edit smart link: %s') % smart_link
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
@@ -178,9 +178,9 @@ def smart_link_delete(request, smart_link_pk):
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
smart_link.delete()
|
||||
messages.success(request, _(u'Smart link: %s deleted successfully.') % smart_link)
|
||||
messages.success(request, _('Smart link: %s deleted successfully.') % smart_link)
|
||||
except Exception as exception:
|
||||
messages.error(request, _(u'Error deleting smart link: %(smart_link)s; %(exception)s.') % {
|
||||
messages.error(request, _('Error deleting smart link: %(smart_link)s; %(exception)s.') % {
|
||||
'smart_link': smart_link,
|
||||
'exception': exception
|
||||
})
|
||||
@@ -189,7 +189,7 @@ def smart_link_delete(request, smart_link_pk):
|
||||
return render_to_response('main/generic_confirm.html', {
|
||||
'delete_view': True,
|
||||
'object': smart_link,
|
||||
'title': _(u'Are you sure you wish to delete smart link: %s?') % smart_link,
|
||||
'title': _('Are you sure you wish to delete smart link: %s?') % smart_link,
|
||||
'next': next,
|
||||
'previous': previous,
|
||||
}, context_instance=RequestContext(request))
|
||||
@@ -226,10 +226,10 @@ def smart_link_condition_list(request, smart_link_pk):
|
||||
AccessEntry.objects.check_accesses([PERMISSION_SMART_LINK_EDIT], request.user, smart_link)
|
||||
|
||||
return render_to_response('main/generic_list.html', {
|
||||
'title': _(u'Conditions for smart link: %s') % smart_link,
|
||||
'title': _('Conditions for smart link: %s') % smart_link,
|
||||
'object_list': smart_link.conditions.all(),
|
||||
'extra_columns': [
|
||||
{'name': _(u'Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))},
|
||||
{'name': _('Enabled'), 'attribute': encapsulate(lambda x: two_state_template(x.enabled))},
|
||||
],
|
||||
'hide_link': True,
|
||||
'object': smart_link,
|
||||
@@ -251,14 +251,14 @@ def smart_link_condition_create(request, smart_link_pk):
|
||||
new_smart_link_condition = form.save(commit=False)
|
||||
new_smart_link_condition.smart_link = smart_link
|
||||
new_smart_link_condition.save()
|
||||
messages.success(request, _(u'Smart link condition: "%s" created successfully.') % new_smart_link_condition)
|
||||
messages.success(request, _('Smart link condition: "%s" created successfully.') % new_smart_link_condition)
|
||||
return HttpResponseRedirect(reverse('linking:smart_link_condition_list', args=[smart_link.pk]))
|
||||
else:
|
||||
form = SmartLinkConditionForm()
|
||||
|
||||
return render_to_response('main/generic_form.html', {
|
||||
'form': form,
|
||||
'title': _(u'Add new conditions to smart link: "%s"') % smart_link,
|
||||
'title': _('Add new conditions to smart link: "%s"') % smart_link,
|
||||
'object': smart_link,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@@ -278,21 +278,21 @@ def smart_link_condition_edit(request, smart_link_condition_pk):
|
||||
form = SmartLinkConditionForm(request.POST, instance=smart_link_condition)
|
||||
if form.is_valid():
|
||||
smart_link_condition = form.save()
|
||||
messages.success(request, _(u'Smart link condition: "%s" edited successfully.') % smart_link_condition)
|
||||
messages.success(request, _('Smart link condition: "%s" edited successfully.') % smart_link_condition)
|
||||
return HttpResponseRedirect(next)
|
||||
else:
|
||||
form = SmartLinkConditionForm(instance=smart_link_condition)
|
||||
|
||||
return render_to_response('main/generic_form.html', {
|
||||
'form': form,
|
||||
'title': _(u'Edit smart link condition'),
|
||||
'title': _('Edit smart link condition'),
|
||||
'next': next,
|
||||
'previous': previous,
|
||||
'condition': smart_link_condition,
|
||||
'object': smart_link_condition.smart_link,
|
||||
'navigation_object_list': [
|
||||
{'object': 'object', 'name': _(u'Smart link')},
|
||||
{'object': 'condition', 'name': _(u'Condition')}
|
||||
{'object': 'object', 'name': _('Smart link')},
|
||||
{'object': 'condition', 'name': _('Condition')}
|
||||
],
|
||||
|
||||
}, context_instance=RequestContext(request))
|
||||
@@ -312,9 +312,9 @@ def smart_link_condition_delete(request, smart_link_condition_pk):
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
smart_link_condition.delete()
|
||||
messages.success(request, _(u'Smart link condition: "%s" deleted successfully.') % smart_link_condition)
|
||||
messages.success(request, _('Smart link condition: "%s" deleted successfully.') % smart_link_condition)
|
||||
except Exception as exception:
|
||||
messages.error(request, _(u'Error deleting smart link condition: %(smart_link_condition)s; %(exception)s.') % {
|
||||
messages.error(request, _('Error deleting smart link condition: %(smart_link_condition)s; %(exception)s.') % {
|
||||
'smart_link_condition': smart_link_condition,
|
||||
'exception': exception
|
||||
})
|
||||
@@ -325,10 +325,10 @@ def smart_link_condition_delete(request, smart_link_condition_pk):
|
||||
'condition': smart_link_condition,
|
||||
'object': smart_link_condition.smart_link,
|
||||
'navigation_object_list': [
|
||||
{'object': 'object', 'name': _(u'Smart link')},
|
||||
{'object': 'condition', 'name': _(u'Condition')}
|
||||
{'object': 'object', 'name': _('Smart link')},
|
||||
{'object': 'condition', 'name': _('Condition')}
|
||||
],
|
||||
'title': _(u'Are you sure you wish to delete smart link condition: "%s"?') % smart_link_condition,
|
||||
'title': _('Are you sure you wish to delete smart link condition: "%s"?') % smart_link_condition,
|
||||
'next': next,
|
||||
'previous': previous,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
Reference in New Issue
Block a user