Commit Graph

50 Commits

Author SHA1 Message Date
Michael Price
34fc5a5bcf Don't error out when there are no metadata types available.
Signed-off-by: Michael Price <loneviking72@gmail.com>
2018-04-01 01:52:11 -04:00
Roberto Rosario
95157460cb Add new UI method to switch between required metadata and optional
metadata without incurring in metadata value loss.
Add modifying relationship of document type and metadata type
from the document type and from the metadata type views.
Closes GitLab issues #337 #373.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
2017-07-05 04:39:54 -04:00
Roberto Rosario
2cc9efc5b2 Make sure lookup selection widgets also trigger the
metadata update checkbox on change.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
2017-07-04 02:02:25 -04:00
Roberto Rosario
5798cabd7c Add support to update the document indexes from workflow state changes.
Add a new workflow field called internal_name for easier workflow
reference in document index templates.
Generalize the PropertyHelper class.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
2017-06-06 20:07:15 -04:00
Roberto Rosario
76e8fd2b07 Auto select checkbox when updating metadata values.
Closes GitLab issue #371.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
2017-05-24 02:28:31 -04:00
Roberto Rosario
22a14d6a20 Fix document add metadata view and form to work when there are no documents in the view.
ie: when the user has no permissions.
2017-01-14 03:08:53 -04:00
Roberto Rosario
5167bbadee Refactor the document metadata add, edit and remove views. 2016-12-28 00:57:04 -04:00
Roberto Rosario
084f6d4b2f Add an aditional step to verify that the update button is checked on required metadata types. 2016-05-12 01:35:08 -04:00
Roberto Rosario
6bf352ecbb Fix queryset assigment, should always be of MetadataType not DocumentTypeMetadataType, errors out on Postgres. 2016-03-15 18:39:48 -04:00
Roberto Rosario
9da4710c0f Deselect the update checkbox for optional metadata by default. 2016-03-08 02:38:15 -04:00
Roberto Rosario
f3d1faebf1 Move metadata form value validation to .clean() and update field data may not be available yet when validatng the value field. Only validate form value if form has a metadata type associated. 2016-02-10 02:27:42 -04:00
Roberto Rosario
f1b090f8d6 Don't store empty metadata value if the update checkbox is not checked. 2016-02-09 19:41:43 -04:00
Roberto Rosario
ca326440a2 Revert "Add ability to disable the metadata update column. Disable the metadata update column in the new document upload wizard."
This reverts commit 511e397850.
2016-02-09 19:37:52 -04:00
Roberto Rosario
511e397850 Add ability to disable the metadata update column. Disable the metadata update column in the new document upload wizard. 2016-02-09 13:43:58 -04:00
Roberto Rosario
9708c76646 Improve coding style. Don't change initial kwargs using .pop. 2015-10-10 02:42:42 -04:00
Roberto Rosario
86ff835839 PEP8 Cleanups. 2015-10-07 22:24:44 -04:00
Roberto Rosario
7392e80fc2 PEP8 Cleanups. 2015-08-24 20:55:45 -04:00
Roberto Rosario
9599a3f8ab Split metadata validators in validators and parsers. Move document and upload wizard metadata validation logic to model. Add metadata tests. 2015-08-20 04:37:49 -04:00
Roberto Rosario
3b728328ad PEP8 cleanups, E501. 2015-07-23 04:05:29 -04:00
Roberto Rosario
0a0a92116e Get rid of eval in metadata type default and lookup fields. gh-issue #151. 2015-07-23 02:49:29 -04:00
Roberto Rosario
58d919d173 Initial commit to remove use of eval. gh-issue #151. 2015-07-22 23:19:43 -04:00
Roberto Rosario
e891fe9525 PEP8 cleanups and code style cleanups. 2015-07-10 17:19:36 -04:00
Roberto Rosario
498f258f59 Convert metadata edit, delete and create views to CBV. Remove unused metadata type form. 2015-07-09 01:19:20 -04:00
Roberto Rosario
f4bcab2341 Rename metadata type title field to label. 2015-07-07 23:25:05 -04:00
Roberto Rosario
6ceb71d0b3 Rename metadata parsers to metadata validators. Fix validators calling method, import and instance, instead previous key based lookup. 2015-06-30 17:35:35 -04:00
Roberto Rosario
c249b47b79 Finish smart settings refactor 2015-06-23 01:44:57 -04:00
Roberto Rosario
78198f3398 Smart settings refactor 2015-06-22 21:04:06 -04:00
Roberto Rosario
d59ea3ede2 Add from __future__ import unicode_literals, issue #37 2015-01-19 04:06:40 -04:00
Roberto Rosario
4dfecb4614 Refactore form clean code for value validation or parsing, issue #104. 2015-01-14 16:55:01 -04:00
Roberto Rosario
490e9a1e42 Remove value field from the document metadata remove form to avoid running validation on remove and blocking removal when validation didn't pass 2015-01-14 15:58:04 -04:00
Roberto Rosario
aca9d8c9eb Remove unused imports, do PEP8 and DeprecationWarning cleanups 2015-01-05 14:40:59 -04:00
Roberto Rosario
c195f74310 Fix document type metadata type references 2015-01-05 05:13:09 -04:00
Roberto Rosario
ac928d028a Use a more sensible default 2014-12-08 23:37:01 -04:00
Roberto Rosario
9f2692d36a PEP8 cleanup, unused import removal 2014-11-02 21:20:29 -04:00
Roberto Rosario
09f4280f58 Only display metadata allowed for this document type in the add metadata view 2014-10-30 15:23:57 -04:00
Roberto Rosario
8ac8292ad8 Enable required metadata types in the metadata selection form 2014-10-30 03:21:09 -04:00
Roberto Rosario
2ea48bd1ba PEP8 cleanups, further removal of unused code 2014-10-21 19:28:52 -04:00
Roberto Rosario
ce39a775ee Issue #88, remove metadata type selection step from interactive upload wizard
Max wizard steps is now 2. Second step is skiped when document type
has not associated metadata types.
2014-10-21 19:02:31 -04:00
Roberto Rosario
92c76d9f33 Issue #56, Remove Metadata Sets 2014-10-21 17:14:31 -04:00
Roberto Rosario
a75a4edf21 Issue #39, Finish capitalizing source text messages 2014-10-10 02:29:37 -04:00
Roberto Rosario
8bac1525be PEP8 cleanups 2014-10-08 19:39:16 -04:00
Roberto Rosario
50e143e754 Fix indentation 2014-10-08 18:15:19 -04:00
Roberto Rosario
97dcf507ab PEP8 cleanups 2014-10-08 18:14:05 -04:00
Roberto Rosario
78ecee7266 Merge branch 'gwalborn-master' into test
Conflicts:
	mayan/apps/metadata/forms.py
2014-10-07 13:47:02 -04:00
Roberto Rosario
74cf4c413f Import cleanups, reorganization, PEP8 cleanups 2014-10-02 02:01:08 -04:00
Roberto Rosario
06dd1b3368 Issue #39, Explicitly captalize string now that they are not capitalized blindly by the templates 2014-10-02 01:17:27 -04:00
Gary Walborn
9cd3753746 Adds ability to validate and normalize metadata.
I felt that it would be very handy to be able to validate
user-supplied metadata.  It occurred to me that if a metadata
type had an explicit list of options, it would need no validation.
Therefore, the "lookup" field of a metadata type could be overloaded
to provide EITHER a list of items that could be selected by the user
OR a function to provide data validation.  The system, therefore,
would need to be able to discriminate between a lookup function
and a validation function.

    To this end, I created a global variable
('METADATA_AVAILABLE_VALIDATORS') to contain a dictionary of
available validation functions.  If the name specified in
'metadata_type.lookup' is present in METADATA_AVAILABLE_VALIDATORS,
the system treats the function as a validator.  Otherwise, the
function is treated as a generator of an iterable value providing
the choices for the user.

  Django contains a pre-existing mechanism to support field
validation.  A validator has a single argument (the data to
be validated).  If the argument to the validator is valid,
the validator simply returns.  If there is a problem with
the data, the validator raises a 'ValidationError' exception
and passes an error message which is then displayed by Django
as a mouseover tip in the browser. Validators to be used
with Mayan-EDMS may follow this convention (i.e., take a
single argument and raise an exception if the validation
fails).  The validators in Mayan-EDMS, however, may actually
do more!

  If a validator function RETURNS a value, that value is used
in place of the original data.  This allows the validator to
make data conform to a valid value or to "normalize" a value
before it is stored in the database.  This allows for more
uniform metadata and improves the ability to index on the
metadata values.  Lets take at a look at an example of this
functionality.

  Assume that a document requires a date (perhaps, an
"original posting date").  We can have a 'metadata_type" of
"original_posting_date", and we can create a validator with
the name "is_valid_posting_date".  The validator function
(which is placed in a module read by the settings routine),
contains the function:

def is_valid_posting_date(value):
   from dateutil import parser
   import datetime
   from django.core.exceptions import ValidationError

   try:
      dt = parser.parse(value)
   except ValueError:
      raise ValidationError('Invalid date')
   return dt.date().isoformat()

This is placed in a dictionary in the user's
settings file, thus:

import my_settings
METADATA_AVAILABLE_VALIDATORS = {
  'is_valid_posting_date':my_settings.is_valid_posting_date }

The user creates a metadata type called "original_posting_date"
with a label of "Original Posting Date" and a 'lookup' value
of "is_valid_posting_date".  When the metadata form is filled
in and submitted, the date value is validated by our validator.
Since the python 'parser' function accepts many kinds of input,
the user can enter (for example) '9/1/2014', '2014/10/2',
or even 'Feb 4, 2001'.  If the user enters something that
does not (as far as python is concerned) represent a valid date,
the system will raise a "ValidationError" and the form will
be re-displayed with an appropriate error message.  If, however,
the data is valid, the valid of the field (and, hence, stored
in the database) will be "normalized" to ISO format YYYY-MM-DD.
This allows consistent lookup and indexing regardless of the
users particular idiosyncracies.
2014-09-22 12:30:15 -04:00
Roberto Rosario
b761037d99 Move all settings files from <app>/conf/settings.py to <app>/settings.py 2014-09-11 05:02:40 -04:00
Roberto Rosario
7321b12c7d Update remaining exception syntaxes 2014-07-20 22:44:12 -04:00
Roberto Rosario
ec1745b50b Initial changes to support the new Django 1.6 project structure 2014-06-15 13:13:21 +02:00