Added tag editing view and listing documents with an specific tag

This commit is contained in:
Roberto Rosario
2011-04-28 21:30:37 -04:00
parent 2532a0a2d8
commit 675bdd6112
13 changed files with 271 additions and 137 deletions
+1 -1
View File
@@ -365,7 +365,7 @@ class MetaDataImageWidget(forms.widgets.Widget):
output.append(u'<div style="white-space:nowrap; overflow: auto;">') output.append(u'<div style="white-space:nowrap; overflow: auto;">')
for document in value['group_data']: for document in value['group_data']:
tags_template = [] tags_template = []
tag_block_template = u'<div style="padding: 1px; border: 1px solid black; background: %s;">%s</div>' tag_block_template = u'<div style="padding: 0px 5px 0px 5px; border: 1px solid black; background: %s;">%s</div>'
tag_count = document.tags.count() tag_count = document.tags.count()
if tag_count: if tag_count:
tags_template.append(u'<div class="tc">') tags_template.append(u'<div class="tc">')
+78 -80
View File
@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-04-28 00:37-0400\n" "POT-Creation-Date: 2011-04-28 21:29-0400\n"
"PO-Revision-Date: 2011-04-28 00:17\n" "PO-Revision-Date: 2011-04-28 00:17\n"
"Last-Translator: Roberto Rosario <rosario_r@jp.pr.gov>\n" "Last-Translator: Roberto Rosario <rosario_r@jp.pr.gov>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -195,11 +195,11 @@ msgstr "Documentos"
msgid "thumbnail" msgid "thumbnail"
msgstr "miniatura" msgstr "miniatura"
#: __init__.py:136 views.py:295 views.py:852 #: __init__.py:136 views.py:297 views.py:846
msgid "metadata" msgid "metadata"
msgstr "metadatos" msgstr "metadatos"
#: __init__.py:143 __init__.py:149 models.py:65 views.py:76 #: __init__.py:143 __init__.py:149 models.py:65 views.py:74
msgid "documents" msgid "documents"
msgstr "documentos" msgstr "documentos"
@@ -268,15 +268,15 @@ msgstr "paso 2 de 2: Metadatos de documento"
msgid "Tags" msgid "Tags"
msgstr "Etiquetas" msgstr "Etiquetas"
#: forms.py:406 views.py:277 #: forms.py:402 views.py:274
msgid "Pages" msgid "Pages"
msgstr "Páginas" msgstr "Páginas"
#: forms.py:407 #: forms.py:403
msgid "Select" msgid "Select"
msgstr "Seleccionar" msgstr "Seleccionar"
#: forms.py:416 #: forms.py:412
msgid "Click on the image for full size view of the first page." msgid "Click on the image for full size view of the first page."
msgstr "Haga clic en la imagen para ver la primera página en tamaño completo" msgstr "Haga clic en la imagen para ver la primera página en tamaño completo"
@@ -309,7 +309,7 @@ msgid "description"
msgstr "descripción" msgstr "descripción"
#: models.py:64 models.py:238 models.py:265 models.py:436 models.py:450 #: models.py:64 models.py:238 models.py:265 models.py:436 models.py:450
#: views.py:383 #: views.py:373
msgid "document" msgid "document"
msgstr "documento" msgstr "documento"
@@ -398,7 +398,7 @@ msgstr "índices de metadatos"
msgid "metadata value" msgid "metadata value"
msgstr "datos de metadato" msgstr "datos de metadato"
#: models.py:246 models.py:247 views.py:91 #: models.py:246 models.py:247 views.py:88
msgid "document metadata" msgid "document metadata"
msgstr "metadatos de documento" msgstr "metadatos de documento"
@@ -570,15 +570,15 @@ msgstr "artículo de grupo de documentos"
msgid "group items" msgid "group items"
msgstr "artículos de grupos de documentos" msgstr "artículos de grupos de documentos"
#: models.py:411 views.py:668 #: models.py:411 views.py:658
msgid "order" msgid "order"
msgstr "orden" msgstr "orden"
#: models.py:412 views.py:669 views.py:709 #: models.py:412 views.py:659 views.py:699
msgid "transformation" msgid "transformation"
msgstr "transformación" msgstr "transformación"
#: models.py:413 views.py:670 #: models.py:413 views.py:660
msgid "arguments" msgid "arguments"
msgstr "argumentos" msgstr "argumentos"
@@ -607,7 +607,7 @@ msgstr "accesado"
msgid "recent document" msgid "recent document"
msgstr "documento reciente" msgstr "documento reciente"
#: models.py:447 views.py:1041 #: models.py:447 views.py:1023
msgid "recent documents" msgid "recent documents"
msgstr "documentos recientes" msgstr "documentos recientes"
@@ -659,223 +659,215 @@ msgstr "Páginas de documentos en la base de datos: %d"
msgid "Document statistics" msgid "Document statistics"
msgstr "Estadísticas de documentos" msgstr "Estadísticas de documentos"
#: views.py:150 #: views.py:147
#, python-format #, python-format
msgid "Extracted file: %s, uploaded successfully." msgid "Extracted file: %s, uploaded successfully."
msgstr "Archivo extraido: %s, ha subido con éxito." msgstr "Archivo extraido: %s, ha subido con éxito."
#: views.py:176 #: views.py:173
msgid "Document uploaded successfully." msgid "Document uploaded successfully."
msgstr "Documento subido con éxito." msgstr "Documento subido con éxito."
#: views.py:194 #: views.py:191
#, python-format #, python-format
msgid "Staging file: %s, uploaded successfully." msgid "Staging file: %s, uploaded successfully."
msgstr "Archivo de ensayo: %s, ha subido con éxito." msgstr "Archivo de ensayo: %s, ha subido con éxito."
#: views.py:198 #: views.py:195
#, python-format #, python-format
msgid "Staging file: %s, deleted successfully." msgid "Staging file: %s, deleted successfully."
msgstr "Archivo de ensayo: %s, eliminado con éxito." msgstr "Archivo de ensayo: %s, eliminado con éxito."
#: views.py:212 #: views.py:209
msgid "upload a local document" msgid "upload a local document"
msgstr "subir un documento local" msgstr "subir un documento local"
#: views.py:230 #: views.py:227
msgid "files in staging" msgid "files in staging"
msgstr "archivos de ensayo" msgstr "archivos de ensayo"
#: views.py:239 #: views.py:236
msgid "upload a document from staging" msgid "upload a document from staging"
msgstr "subir un documento de ensayo" msgstr "subir un documento de ensayo"
#: views.py:248 #: views.py:245
msgid "Current metadata" msgid "Current metadata"
msgstr "metadatos actuales" msgstr "metadatos actuales"
#: views.py:266 #: views.py:263
msgid "Filename" msgid "Filename"
msgstr "Nombre del archivo" msgstr "Nombre del archivo"
#: views.py:267 #: views.py:264
msgid "File extension" msgid "File extension"
msgstr "Extensión de archivo" msgstr "Extensión de archivo"
#: views.py:268 #: views.py:265
msgid "File mimetype" msgid "File mimetype"
msgstr "Tipo MIME del archivo" msgstr "Tipo MIME del archivo"
#: views.py:269 #: views.py:266
msgid "File mime encoding" msgid "File mime encoding"
msgstr "Codificación de archivos MIME" msgstr "Codificación de archivos MIME"
#: views.py:270 #: views.py:267
msgid "File size" msgid "File size"
msgstr "Tamaños del archivo" msgstr "Tamaños del archivo"
#: views.py:271 #: views.py:268
msgid "Exists in storage" msgid "Exists in storage"
msgstr "Existe en el almacenamiento" msgstr "Existe en el almacenamiento"
#: views.py:272 #: views.py:269
msgid "File path in storage" msgid "File path in storage"
msgstr "Ruta de archivos en el almacenamiento" msgstr "Ruta de archivos en el almacenamiento"
#: views.py:273 #: views.py:270
msgid "Date added" msgid "Date added"
msgstr "Fecha en que se agregó" msgstr "Fecha en que se agregó"
#: views.py:274 #: views.py:271
msgid "Time added" msgid "Time added"
msgstr "El tiempo añadido" msgstr "El tiempo añadido"
#: views.py:275 #: views.py:272
msgid "Checksum" msgid "Checksum"
msgstr "Suma de comprobación" msgstr "Suma de comprobación"
#: views.py:276 #: views.py:273
msgid "UUID" msgid "UUID"
msgstr "UUID" msgstr "UUID"
#: views.py:287 views.py:843 #: views.py:284 views.py:833
msgid "document properties" msgid "document properties"
msgstr "propiedades del documento" msgstr "propiedades del documento"
#: views.py:297 views.py:854 #: views.py:299 views.py:848
msgid "value" msgid "value"
msgstr "valor" msgstr "valor"
#: views.py:305 views.py:862 #: views.py:307 views.py:856
#, python-format #, python-format
msgid "Document group query error: %s" msgid "Document group query error: %s"
msgstr "Drror de consulta de grupo de documentos: %s" msgstr "Drror de consulta de grupo de documentos: %s"
#: views.py:315 views.py:872 #: views.py:317 views.py:866
#, python-format #, python-format
msgid "document groups (%s)" msgid "document groups (%s)"
msgstr "grupo de documentos (%s)" msgstr "grupo de documentos (%s)"
#: views.py:328 views.py:888 #: views.py:330
msgid "tags"
msgstr "etiquetas"
#: views.py:331 views.py:891
msgid "color"
msgstr "color"
#: views.py:340
msgid "index links" msgid "index links"
msgstr "enlaces de índice" msgstr "enlaces de índice"
#: views.py:363 views.py:467 views.py:787 #: views.py:353 views.py:457 views.py:777
msgid "Must provide at least one document." msgid "Must provide at least one document."
msgstr "Debe proveer al menos un documento." msgstr "Debe proveer al menos un documento."
#: views.py:374 #: views.py:364
#, python-format #, python-format
msgid "Document: %s deleted successfully." msgid "Document: %s deleted successfully."
msgstr "Documento: %s eliminado con éxito." msgstr "Documento: %s eliminado con éxito."
#: views.py:376 #: views.py:366
#, python-format #, python-format
msgid "Document: %(document)s delete error: %(error)s" msgid "Document: %(document)s delete error: %(error)s"
msgstr "Documento: %(document)s, error de eliminación: %(error)s " msgstr "Documento: %(document)s, error de eliminación: %(error)s "
#: views.py:390 #: views.py:380
#, python-format #, python-format
msgid "Are you sure you wish to delete the document: %s?" msgid "Are you sure you wish to delete the document: %s?"
msgstr "¿Está seguro que desea eliminar el documento: %s?" msgstr "¿Está seguro que desea eliminar el documento: %s?"
#: views.py:392 #: views.py:382
#, python-format #, python-format
msgid "Are you sure you wish to delete the documents: %s?" msgid "Are you sure you wish to delete the documents: %s?"
msgstr "¿Está seguro que desea eliminar los documentos: %s?" msgstr "¿Está seguro que desea eliminar los documentos: %s?"
#: views.py:431 #: views.py:421
#, python-format #, python-format
msgid "Document %s edited successfully." msgid "Document %s edited successfully."
msgstr "Documento %s editado con éxito." msgstr "Documento %s editado con éxito."
#: views.py:440 #: views.py:430
msgid "Document filesystem links updated successfully." msgid "Document filesystem links updated successfully."
msgstr "Enlaces del documento actualizados con éxito." msgstr "Enlaces del documento actualizados con éxito."
#: views.py:464 #: views.py:454
msgid "All documents must be from the same type." msgid "All documents must be from the same type."
msgstr "Todos los documentos deben ser del mismo tipo." msgstr "Todos los documentos deben ser del mismo tipo."
#: views.py:499 #: views.py:489
#, python-format #, python-format
msgid "Error deleting filesystem links for document: %(document)s; %(error)s" msgid "Error deleting filesystem links for document: %(document)s; %(error)s"
msgstr "" msgstr ""
"Error al eliminar los enlaces del sistema de archivos para el documento: " "Error al eliminar los enlaces del sistema de archivos para el documento: "
"%(document)s; %(error)s " "%(document)s; %(error)s "
#: views.py:502 #: views.py:492
#, python-format #, python-format
msgid "Metadata for document %s edited successfully." msgid "Metadata for document %s edited successfully."
msgstr "Metadatos para documento %s editado con éxito." msgstr "Metadatos para documento %s editado con éxito."
#: views.py:511 #: views.py:501
#, python-format #, python-format
msgid "Filesystem links updated successfully for document: %s." msgid "Filesystem links updated successfully for document: %s."
msgstr "" msgstr ""
"Enlaces del sistema de archivos actualizados con éxito para el documento: %s." "Enlaces del sistema de archivos actualizados con éxito para el documento: %s."
#: views.py:513 #: views.py:503
#, python-format #, python-format
msgid "Error creating filesystem links for document: %(document)s; %(error)s" msgid "Error creating filesystem links for document: %(document)s; %(error)s"
msgstr "" msgstr ""
"Error al crear vínculos de sistema de archivos para el documento: " "Error al crear vínculos de sistema de archivos para el documento: "
"%(document)s; %(error)s " "%(document)s; %(error)s "
#: views.py:527 #: views.py:517
#, python-format #, python-format
msgid "Edit metadata for document: %s" msgid "Edit metadata for document: %s"
msgstr "Editar de metadatos para el documento: %s" msgstr "Editar de metadatos para el documento: %s"
#: views.py:529 #: views.py:519
#, python-format #, python-format
msgid "Edit metadata for documents: %s" msgid "Edit metadata for documents: %s"
msgstr "Editar metadatos para los documentos: %s" msgstr "Editar metadatos para los documentos: %s"
#: views.py:551 #: views.py:541
#, python-format #, python-format
msgid "Page transformation error: %s" msgid "Page transformation error: %s"
msgstr "Error de transformación de página: %s" msgstr "Error de transformación de página: %s"
#: views.py:612 #: views.py:602
#, python-format #, python-format
msgid "Staging file transformation error: %(error)s" msgid "Staging file transformation error: %(error)s"
msgstr "Error de transformación de archivo de ensayo: %(error)s " msgstr "Error de transformación de archivo de ensayo: %(error)s "
#: views.py:641 #: views.py:631
msgid "Staging file delete successfully." msgid "Staging file delete successfully."
msgstr "Archivo de ensayo eliminado con éxito." msgstr "Archivo de ensayo eliminado con éxito."
#: views.py:665 #: views.py:655
#, python-format #, python-format
msgid "transformations for: %s" msgid "transformations for: %s"
msgstr "transformaciones para: %s" msgstr "transformaciones para: %s"
#: views.py:694 #: views.py:684
#, python-format #, python-format
msgid "Create new transformation for page: %(page)s of document: %(document)s" msgid "Create new transformation for page: %(page)s of document: %(document)s"
msgstr "" msgstr ""
"Crear nueva transformación de la página: %(page)s del documento: " "Crear nueva transformación de la página: %(page)s del documento: "
"%(document)s " "%(document)s "
#: views.py:710 #: views.py:700
#, python-format #, python-format
msgid "Edit transformation \"%(transformation)s\" for: %(document_page)s" msgid "Edit transformation \"%(transformation)s\" for: %(document_page)s"
msgstr "Editar transformación \" %(transformation)s\" para: %(document_page)s" msgstr "Editar transformación \" %(transformation)s\" para: %(document_page)s"
#: views.py:731 views.py:807 #: views.py:721 views.py:797
msgid "document transformation" msgid "document transformation"
msgstr "transformación de documento" msgstr "transformación de documento"
#: views.py:732 #: views.py:722
#, python-format #, python-format
msgid "" msgid ""
"Are you sure you wish to delete transformation \"%(transformation)s\" for: " "Are you sure you wish to delete transformation \"%(transformation)s\" for: "
@@ -884,17 +876,17 @@ msgstr ""
"¿Está seguro que desea eliminar la transformación \"%(transformation)s\" " "¿Está seguro que desea eliminar la transformación \"%(transformation)s\" "
"para: %(document_page)s" "para: %(document_page)s"
#: views.py:753 views.py:913 #: views.py:743 views.py:895
msgid "On large databases this operation may take some time to execute." msgid "On large databases this operation may take some time to execute."
msgstr "" msgstr ""
"En bases de datos de gran tamaño esta operación puede tardar algún tiempo en " "En bases de datos de gran tamaño esta operación puede tardar algún tiempo en "
"ejecutarse." "ejecutarse."
#: views.py:767 #: views.py:757
msgid "duplicated documents" msgid "duplicated documents"
msgstr "documentos duplicados" msgstr "documentos duplicados"
#: views.py:799 #: views.py:789
#, python-format #, python-format
msgid "" msgid ""
"All the page transformations for document: %s, have been deleted " "All the page transformations for document: %s, have been deleted "
@@ -903,7 +895,7 @@ msgstr ""
"Todas las transformaciones de la página de documento: %s, se han eliminado " "Todas las transformaciones de la página de documento: %s, se han eliminado "
"con éxito." "con éxito."
#: views.py:801 #: views.py:791
#, python-format #, python-format
msgid "" msgid ""
"Error deleting the page transformations for document: %(document)s; " "Error deleting the page transformations for document: %(document)s; "
@@ -912,7 +904,7 @@ msgstr ""
"Error al eliminar las transformaciones de página para el documento: " "Error al eliminar las transformaciones de página para el documento: "
"%(document)s; %(error)s." "%(document)s; %(error)s."
#: views.py:815 #: views.py:805
#, python-format #, python-format
msgid "" msgid ""
"Are you sure you wish to clear all the page transformations for document: %s?" "Are you sure you wish to clear all the page transformations for document: %s?"
@@ -920,7 +912,7 @@ msgstr ""
"¿Está seguro que desea eliminar todas las transformaciones de página del " "¿Está seguro que desea eliminar todas las transformaciones de página del "
"documento: %s?" "documento: %s?"
#: views.py:817 #: views.py:807
#, python-format #, python-format
msgid "" msgid ""
"Are you sure you wish to clear all the page transformations for documents: " "Are you sure you wish to clear all the page transformations for documents: "
@@ -929,37 +921,37 @@ msgstr ""
"¿Está seguro que desea eliminar las transformaciones de página de los " "¿Está seguro que desea eliminar las transformaciones de página de los "
"documentos: %s?" "documentos: %s?"
#: views.py:923 #: views.py:905
msgid "missing documents" msgid "missing documents"
msgstr "documentos perdidos" msgstr "documentos perdidos"
#: views.py:939 views.py:958 #: views.py:921 views.py:940
#, python-format #, python-format
msgid "details for: %s" msgid "details for: %s"
msgstr "detalles para: %s" msgstr "detalles para: %s"
#: views.py:979 #: views.py:961
msgid "Document page edited successfully." msgid "Document page edited successfully."
msgstr "Página del documento se ha editado correctamente." msgstr "Página del documento se ha editado correctamente."
#: views.py:987 #: views.py:969
#, python-format #, python-format
msgid "edit: %s" msgid "edit: %s"
msgstr "editar: %s" msgstr "editar: %s"
#: views.py:998 #: views.py:980
msgid "There are no more pages in this document" msgid "There are no more pages in this document"
msgstr "No hay más páginas en este documento" msgstr "No hay más páginas en este documento"
#: views.py:1011 #: views.py:993
msgid "You are already at the first page of this document" msgid "You are already at the first page of this document"
msgstr "Usted ya está en la primera página de este documento" msgstr "Usted ya está en la primera página de este documento"
#: views.py:1109 #: views.py:1091
msgid "No action selected." msgid "No action selected."
msgstr "Ninguna acción seleccionada." msgstr "Ninguna acción seleccionada."
#: views.py:1125 #: views.py:1107
#, python-format #, python-format
msgid "documents in group: %(group)s, for document: %(document)s" msgid "documents in group: %(group)s, for document: %(document)s"
msgstr "grupo de documentos: %(group)s, para el documento: %(document)s " msgstr "grupo de documentos: %(group)s, para el documento: %(document)s "
@@ -968,6 +960,12 @@ msgstr "grupo de documentos: %(group)s, para el documento: %(document)s "
msgid "Rotate [degrees]" msgid "Rotate [degrees]"
msgstr "Rotar [degrees]" msgstr "Rotar [degrees]"
#~ msgid "tags"
#~ msgstr "etiquetas"
#~ msgid "color"
#~ msgstr "color"
#~ msgid "metadata groups (%s)" #~ msgid "metadata groups (%s)"
#~ msgstr "grupos de metadatos (%s)" #~ msgstr "grupos de metadatos (%s)"
+7 -11
View File
@@ -66,19 +66,15 @@ PICTURE_UNKNOWN_SMALL = u'1299549572_unknown2.png'
PICTURE_UNKNOWN_MEDIUM = u'1299549805_unknown.png' PICTURE_UNKNOWN_MEDIUM = u'1299549805_unknown.png'
def document_list(request): def document_list(request, object_list=None, title=None):
check_permissions(request.user, 'documents', [PERMISSION_DOCUMENT_VIEW]) check_permissions(request.user, 'documents', [PERMISSION_DOCUMENT_VIEW])
return object_list( return render_to_response('generic_list.html', {
request, 'object_list': object_list if object_list else Document.objects.only('file_filename', 'file_extension').all(),
queryset=Document.objects.only('file_filename', 'file_extension').all(), 'title': title if title else _(u'documents'),
template_name='generic_list.html', 'multi_select_as_buttons': True,
extra_context={ 'hide_links': True,
'title': _(u'documents'), }, context_instance=RequestContext(request))
'multi_select_as_buttons': True,
'hide_links': True,
},
)
def document_create(request, multiple=True): def document_create(request, multiple=True):
@@ -130,6 +130,17 @@ def _get_object_navigation_links(context, menu_name=None, links_dict=object_navi
current_view = resolve_to_name(current_path) current_view = resolve_to_name(current_path)
context_links = [] context_links = []
try:
"""
Override the navigation links dictionary with the provided
link list
"""
navigation_object_links = Variable('navigation_object_links').resolve(context)
if navigation_object_links:
return navigation_object_links
except VariableDoesNotExist:
pass
try: try:
object_name = Variable('navigation_object_name').resolve(context) object_name = Variable('navigation_object_name').resolve(context)
except VariableDoesNotExist: except VariableDoesNotExist:
@@ -140,12 +151,6 @@ def _get_object_navigation_links(context, menu_name=None, links_dict=object_navi
except VariableDoesNotExist: except VariableDoesNotExist:
obj = None obj = None
try:
navigation_object_links = Variable('navigation_object_links').resolve(context)
links_dict = navigation_object_links if navigation_object_links else object_navigation
except VariableDoesNotExist:
pass
try: try:
links = links_dict[menu_name][current_view]['links'] links = links_dict[menu_name][current_view]['links']
for link in resolve_links(context, links, current_view, current_path): for link in resolve_links(context, links, current_view, current_path):
+15 -2
View File
@@ -24,9 +24,23 @@ register_permissions('tags', [
tag_list = {'text': _('tags'), 'view': 'tag_list', 'famfam': 'tag_blue'} tag_list = {'text': _('tags'), 'view': 'tag_list', 'famfam': 'tag_blue'}
tag_document_remove = {'text': _('delete'), 'view': 'tag_remove', 'args': ['object.id', 'document.id'], 'famfam': 'tag_blue_delete', 'permissions': {'namespace': 'tags', 'permissions': [PERMISSION_TAG_REMOVE]}} tag_document_remove = {'text': _('delete'), 'view': 'tag_remove', 'args': ['object.id', 'document.id'], 'famfam': 'tag_blue_delete', 'permissions': {'namespace': 'tags', 'permissions': [PERMISSION_TAG_REMOVE]}}
tag_delete = {'text': _('delete'), 'view': 'tag_delete', 'args': 'object.id', 'famfam': 'tag_blue_delete', 'permissions': {'namespace': 'tags', 'permissions': [PERMISSION_TAG_DELETE]}} tag_delete = {'text': _('delete'), 'view': 'tag_delete', 'args': 'object.id', 'famfam': 'tag_blue_delete', 'permissions': {'namespace': 'tags', 'permissions': [PERMISSION_TAG_DELETE]}}
tag_edit = {'text': _('edit'), 'view': 'tag_edit', 'args': 'object.id', 'famfam': 'tag_blue_edit', 'permissions': {'namespace': 'tags', 'permissions': [PERMISSION_TAG_EDIT]}}
tag_tagged_item_list = {'text': _('tagged documents'), 'view': 'tag_tagged_item_list', 'args': 'object.id', 'famfam': 'tag_blue_edit'}
tag_multiple_delete = {'text': _('delete'), 'view': 'tag_multiple_delete', 'famfam': 'tag_blue_delete', 'permissions': {'namespace': 'tags', 'permissions': [PERMISSION_TAG_DELETE]}} tag_multiple_delete = {'text': _('delete'), 'view': 'tag_multiple_delete', 'famfam': 'tag_blue_delete', 'permissions': {'namespace': 'tags', 'permissions': [PERMISSION_TAG_DELETE]}}
#register_links(Tag, [tag_delete]) register_model_list_columns(Tag, [
{
'name': _(u'color'),
'attribute': lambda x: u'<div style="width: 20px; height: 20px; border: 1px solid black; background: %s;"></div>' %
x.tagproperties_set.get().get_color_code(),
},
{
'name': _(u'color name'),
'attribute': lambda x: x.tagproperties_set.get().get_color_display(),
}
])
register_links(Tag, [tag_tagged_item_list, tag_edit])
register_multi_item_links(['tag_list'], [tag_multiple_delete]) register_multi_item_links(['tag_list'], [tag_multiple_delete])
@@ -39,5 +53,4 @@ tags_menu = [
] ]
}, },
] ]
register_menu(tags_menu) register_menu(tags_menu)
-5
View File
@@ -3,9 +3,4 @@ from django.contrib import admin
from tags.models import TagProperties from tags.models import TagProperties
#class PermissionAdmin(admin.ModelAdmin):
# inlines = [PermissionHolderInline]
# list_display = ('namespace', 'name', 'label')
# list_display_links = list_display
admin.site.register(TagProperties) admin.site.register(TagProperties)
+12
View File
@@ -7,6 +7,18 @@ from models import COLOR_CHOICES
class AddTagForm(forms.Form): class AddTagForm(forms.Form):
"""
Form to be displayed in the sidebar of a document and allow adding
new or existing tags
"""
new_tag = forms.CharField(required=False, label=_(u'New tag')) new_tag = forms.CharField(required=False, label=_(u'New tag'))
color = forms.ChoiceField(choices=COLOR_CHOICES, required=False, label=_(u'Color')) color = forms.ChoiceField(choices=COLOR_CHOICES, required=False, label=_(u'Color'))
existing_tags = forms.ModelChoiceField(required=False, queryset=Tag.objects.all(), label=_(u'Existing tags')) existing_tags = forms.ModelChoiceField(required=False, queryset=Tag.objects.all(), label=_(u'Existing tags'))
class TagForm(forms.Form):
"""
Form to edit an existing tag's properties
"""
name = forms.CharField(label=_(u'Name'))
color = forms.ChoiceField(choices=COLOR_CHOICES, label=_(u'Color'))
Binary file not shown.
+95 -13
View File
@@ -8,8 +8,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-04-28 00:14-0400\n" "POT-Creation-Date: 2011-04-28 21:20-0400\n"
"PO-Revision-Date: 2011-04-28 00:17\n" "PO-Revision-Date: 2011-04-28 21:23\n"
"Last-Translator: Roberto Rosario <rosario_r@jp.pr.gov>\n" "Last-Translator: Roberto Rosario <rosario_r@jp.pr.gov>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@@ -19,22 +19,66 @@ msgstr ""
"X-Translated-Using: django-rosetta 0.5.6\n" "X-Translated-Using: django-rosetta 0.5.6\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: __init__.py:10 #: __init__.py:17
msgid "Create new tags"
msgstr "Crear nuevas etiquetas"
#: __init__.py:18
msgid "Attach exising tags"
msgstr "Anejar etiquetas existentes"
#: __init__.py:19
msgid "Remove tags from documents"
msgstr "Quitar etiquetas de los documentos"
#: __init__.py:20
msgid "Delete global tags"
msgstr "Eliminar las etiquetas globales"
#: __init__.py:21
msgid "Edit global tags"
msgstr "Editar etiquetas globales"
#: __init__.py:24 __init__.py:51 utils.py:13 views.py:73
msgid "tags"
msgstr "etiquetas"
#: __init__.py:25 __init__.py:26 __init__.py:29
msgid "delete" msgid "delete"
msgstr "eliminar" msgstr "eliminar"
#: forms.py:15 #: __init__.py:27
msgid "edit"
msgstr "editar"
#: __init__.py:28
msgid "tagged documents"
msgstr "documentos etiquetados"
#: __init__.py:33 models.py:34
msgid "color"
msgstr "color"
#: __init__.py:38
msgid "color name"
msgstr "nombre del color"
#: forms.py:14
msgid "New tag" msgid "New tag"
msgstr "Nueva etiqueta" msgstr "Nueva etiqueta"
#: forms.py:16 #: forms.py:15 forms.py:24
msgid "Color" msgid "Color"
msgstr "Color" msgstr "Color"
#: forms.py:17 #: forms.py:16
msgid "Existing tags" msgid "Existing tags"
msgstr "Etiquetas existentes" msgstr "Etiquetas existentes"
#: forms.py:23
msgid "Name"
msgstr "Nombre"
#: models.py:14 #: models.py:14
msgid "Blue" msgid "Blue"
msgstr "Azul" msgstr "Azul"
@@ -59,14 +103,10 @@ msgstr "Rojo"
msgid "Yellow" msgid "Yellow"
msgstr "Amarillo" msgstr "Amarillo"
#: models.py:33 #: models.py:33 views.py:108
msgid "tag" msgid "tag"
msgstr "etiqueta" msgstr "etiqueta"
#: models.py:34
msgid "color"
msgstr "color"
#: models.py:37 #: models.py:37
msgid "tag properties" msgid "tag properties"
msgstr "propiedades de etiqueta" msgstr "propiedades de etiqueta"
@@ -75,21 +115,63 @@ msgstr "propiedades de etiqueta"
msgid "tags properties" msgid "tags properties"
msgstr "propiedades de etiquetas" msgstr "propiedades de etiquetas"
#: views.py:25 #: views.py:26
#, python-format #, python-format
msgid "Tag \"%s\" removed successfully." msgid "Tag \"%s\" removed successfully."
msgstr "Etiqueta \"%s\" eliminada exitosamente." msgstr "Etiqueta \"%s\" eliminada exitosamente."
#: views.py:52 #: views.py:52
msgid "Must choose either a new tag or an existing one."
msgstr "Debe elegir una etiqueta nueva o una ya existente."
#: views.py:56
#, python-format #, python-format
msgid "Document is already tagged as \"%s\"" msgid "Document is already tagged as \"%s\""
msgstr "Documento ya está etiquetado como \"%s\"" msgstr "Documento ya está etiquetado como \"%s\""
#: views.py:61 #: views.py:65
#, python-format #, python-format
msgid "Tag \"%s\" added successfully." msgid "Tag \"%s\" added successfully."
msgstr "Etiqueta \"%s\", agregada exitosamente." msgstr "Etiqueta \"%s\", agregada exitosamente."
#: views.py:89
msgid "Must provide at least one tag."
msgstr "Debe proveer al menos una etiqueta."
#: views.py:99
#, python-format
msgid "Tag \"%s\" deleted successfully."
msgstr "Etiqueta \"%s\" borrada exitosamente."
#: views.py:101
#, python-format
msgid "Error deleting tag \"%(tag)s\": %(error)s"
msgstr "Error al eliminar la etiqueta \"%(tag)s\": %(error)s"
#: views.py:115
#, python-format
msgid "Are you sure you wish to delete the tag: %s?"
msgstr "¿Está seguro que desea eliminar la etiqueta: %s?"
#: views.py:116 views.py:119
msgid "Will be removed from all documents."
msgstr "Se eliminará de todos los documentos."
#: views.py:118
#, python-format
msgid "Are you sure you wish to delete the tags: %s?"
msgstr "¿Está seguro que desea eliminar de las etiquetas: %s?"
#: views.py:151
#, python-format
msgid "edit tag: %s"
msgstr "editar la etiqueta: %s"
#: views.py:162
#, python-format
msgid "documents with the tag \"%s\""
msgstr "documentos con la etiqueta \"%s\""
#: templatetags/tags_tags.py:17 #: templatetags/tags_tags.py:17
msgid "Add tag to document" msgid "Add tag to document"
msgstr "Agregar etiqueta al documento" msgstr "Agregar etiqueta al documento"
+2
View File
@@ -3,6 +3,8 @@ from django.conf.urls.defaults import patterns, url
urlpatterns = patterns('tags.views', urlpatterns = patterns('tags.views',
url(r'^list/$', 'tag_list', (), 'tag_list'), url(r'^list/$', 'tag_list', (), 'tag_list'),
url(r'^(?P<tag_id>\d+)/delete/$', 'tag_delete', (), 'tag_delete'), url(r'^(?P<tag_id>\d+)/delete/$', 'tag_delete', (), 'tag_delete'),
url(r'^(?P<tag_id>\d+)/edit/$', 'tag_edit', (), 'tag_edit'),
url(r'^(?P<tag_id>\d+)/tagged_item/list/$', 'tag_tagged_item_list', (), 'tag_tagged_item_list'),
url(r'^multiple/delete/$', 'tag_multiple_delete', (), 'tag_multiple_delete'), url(r'^multiple/delete/$', 'tag_multiple_delete', (), 'tag_multiple_delete'),
url(r'^(?P<tag_id>\d+)/remove_from_document/(?P<document_id>\d+)/$', 'tag_remove', (), 'tag_remove'), url(r'^(?P<tag_id>\d+)/remove_from_document/(?P<document_id>\d+)/$', 'tag_remove', (), 'tag_remove'),
+5 -7
View File
@@ -4,16 +4,14 @@ from tags import tag_document_remove
def get_tags_subtemplate(obj): def get_tags_subtemplate(obj):
"""
Return all the settings to render a subtemplate containing and
object's tags
"""
return { return {
'name': 'generic_list_subtemplate.html', 'name': 'generic_list_subtemplate.html',
'title': _(u'tags'), 'title': _(u'tags'),
'object_list': obj.tags.all(), 'object_list': obj.tags.all(),
'extra_columns': [
{'name': _(u'color'), 'attribute': lambda x: u'<div style="width: 20px; height: 20px; border: 1px solid black; background: %s;"></div>' % x.tagproperties_set.get().get_color_code()},
],
'hide_link': True, 'hide_link': True,
'navigation_object_links': {None: { 'navigation_object_links': [tag_document_remove],
'document_view_simple' : {'links': [tag_document_remove]},
'document_view' : {'links': [tag_document_remove]}
}}
} }
+36 -3
View File
@@ -6,11 +6,11 @@ from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from permissions.api import check_permissions from permissions.api import check_permissions
from taggit.models import Tag from taggit.models import Tag
from documents.models import Document from documents.models import Document
from documents.views import document_list
from tags.forms import AddTagForm from tags.forms import AddTagForm, TagForm
from tags.models import TagProperties from tags.models import TagProperties
from tags import PERMISSION_TAG_CREATE, PERMISSION_TAG_ATTACH, \ from tags import PERMISSION_TAG_CREATE, PERMISSION_TAG_ATTACH, \
PERMISSION_TAG_REMOVE, PERMISSION_TAG_DELETE, PERMISSION_TAG_EDIT PERMISSION_TAG_REMOVE, PERMISSION_TAG_DELETE, PERMISSION_TAG_EDIT
@@ -20,7 +20,6 @@ def tag_remove(request, tag_id, document_id):
check_permissions(request.user, 'tags', [PERMISSION_TAG_REMOVE]) check_permissions(request.user, 'tags', [PERMISSION_TAG_REMOVE])
tag = get_object_or_404(Tag, pk=tag_id) tag = get_object_or_404(Tag, pk=tag_id)
document = get_object_or_404(Document, pk=document_id)
previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', None))) previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', None)))
tag.delete() tag.delete()
@@ -127,3 +126,37 @@ def tag_multiple_delete(request):
return tag_delete( return tag_delete(
request, tag_id_list=request.GET.get('id_list', []) request, tag_id_list=request.GET.get('id_list', [])
) )
def tag_edit(request, tag_id):
check_permissions(request.user, 'tags', [PERMISSION_TAG_EDIT])
tag = get_object_or_404(Tag, pk=tag_id)
if request.method == 'POST':
form = TagForm(request.POST)
if form.is_valid():
tag.name = form.cleaned_data['name']
tag.save()
tag_properties = tag.tagproperties_set.get()
tag_properties.color = form.cleaned_data['color']
tag_properties.save()
return HttpResponseRedirect(reverse('tag_list'))
else:
form = TagForm(initial={
'name': tag.name,
'color': tag.tagproperties_set.get().color
})
return render_to_response('generic_form.html', {
'title': _(u'edit tag: %s') % tag,
'form': form,
'object': tag,
},
context_instance=RequestContext(request))
def tag_tagged_item_list(request, tag_id):
tag = get_object_or_404(Tag, pk=tag_id)
object_list = [tagged_item.content_object for tagged_item in tag.taggit_taggeditem_items.all()]
return document_list(request, object_list=object_list, title=_('documents with the tag "%s"') % tag)