Commit Graph
2794 Commits
Author SHA1 Message Date
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 1050fc71af Fix tag properties reference 2014-09-06 17:29:15 -04:00
Roberto Rosario 77f7245766 Fix typo 2014-08-27 01:34:08 -04:00
Roberto Rosario db10d89117 Add placeholder local.py 2014-08-27 01:32:32 -04:00
Roberto Rosario d5cc5d750c Add overview.gif 2014-08-27 00:54:56 -04:00
Roberto Rosario 7a28fa12c2 Bump version to 1.0 2014-08-26 23:00:35 -04:00
Roberto Rosario 65ecb28c76 Add functional document views test 2014-08-26 22:52:32 -04:00
Roberto Rosario adf4291ea4 Dismiss successful messages after 2.5 seconds 2014-08-26 01:21:37 -04:00
Roberto Rosario bb2885f52e Fix issue #25 2014-08-26 00:27:09 -04:00
Roberto Rosario 77fdefcdf5 Merge remote-tracking branch 'origin/master' 2014-08-18 01:32:04 -04:00
Roberto Rosario 3caa970ea4 Script to workaround but 99 https://bitbucket.org/pypa/wheel/issue/99/cannot-exclude-directory 2014-08-18 01:31:35 -04:00
Roberto Rosario 397b083381 Add contrib files 2014-08-18 01:29:50 -04:00
Roberto Rosario e80209117a Add production settings file and point wsgi by default to it 2014-08-18 01:29:23 -04:00
Roberto Rosario 10a456c847 Remove mayan/settings/local.py and ignore it from git, this is a local install file 2014-08-18 01:28:28 -04:00
Roberto Rosario 8ea069e955 Merge pull request #29 from NacreData/master
minor grammer edits in documentation
2014-08-14 12:33:27 -04:00
Devin Ceartas d0e4e9d3aa minor grammer and typo edits 2014-08-14 16:31:27 +00:00
Devin Ceartas 2187fdfc45 minor grammer edits 2014-08-14 16:26:43 +00:00
Devin Ceartas 2723ea21ce minor grammer edits 2014-08-14 16:17:04 +00:00
Roberto Rosario c3e449c740 Merge pull request #28 from NacreData/master
Adjust .gitignore for new path to /static/, as per commit 47899e29c3886b...
2014-08-12 18:28:59 -04:00
Devin M. Ceartas f1f085f630 Adjust .gitignore for new path to /static/, as per commit 47899e29c3 2014-08-12 22:17:32 +00:00
Roberto Rosario 5ebb550eee Include fonts used by the default theme 2014-08-05 02:50:29 -04:00
Roberto Rosario 47899e29c3 Store every user modifiable data in the /media dir include collected static files 2014-08-05 02:30:23 -04:00
Roberto Rosario 2825bfc97b Merge remote-tracking branch 'origin/master' 2014-07-31 21:39:04 -04:00
Roberto Rosario 718d0f8d59 Include the localization files (.po, .mo) when creating the package 2014-07-31 20:28:06 -04:00
Roberto Rosario 01a0d69a5f Generate new source language files 2014-07-31 20:27:52 -04:00
Roberto Rosario db7178103f Merge pull request #26 from miek770/patch-1
Update bulk_upload.py
2014-07-30 18:57:52 -04:00
Michel 8268804499 Update bulk_upload.py
compressed_files relative import didn't point to the right location.
2014-07-30 18:38:29 -04:00
Roberto Rosario deaf13d2a3 Remove unused imports 2014-07-28 03:25:31 -04:00
Roberto Rosario b3082b5743 Use Django's method to generate the SECRET_KEY setting 2014-07-28 03:23:51 -04:00
Roberto Rosario 4172246358 Add username and email login tests 2014-07-28 03:18:45 -04:00
Roberto Rosario dad8f0fa9d Move CSS markup from form to the template 2014-07-28 03:18:28 -04:00
Roberto Rosario 0d3ce55f39 Don't inherit from Django's default AuthenticationForm
It is for username/password only
2014-07-28 03:17:26 -04:00
Roberto Rosario a3bd6d3f64 Update authentication backend as per Django 1.6 updates 2014-07-28 03:16:52 -04:00
Roberto Rosario b21433dcb2 Show the email of the auto generated admin 2014-07-28 03:16:17 -04:00
Roberto Rosario b98dbd83da Synchronize language translations 2014-07-28 01:22:21 -04:00
Roberto Rosario 6c08d0396d Merge remote-tracking branch 'origin/master' 2014-07-25 21:32:55 -04:00
Roberto Rosario d95a2931d2 Quick fix for issue #24 2014-07-25 21:31:34 -04:00
Roberto Rosario 2c33e2e029 Old remaked and unused code removal 2014-07-25 21:27:30 -04:00
Roberto Rosario 39e596ba3d Don't include anythin in mayan/media 2014-07-24 13:44:08 -04:00
Roberto Rosario 1f98731b78 Don't waste time scanning the 'mayan/media' directory
Is not relevant for packaging and can cause slow execution
if ran from an existing installation
2014-07-24 13:37:18 -04:00
Roberto Rosario 486f59fbfb Update version in instructions 2014-07-24 13:26:25 -04:00
Roberto Rosario 41f34f9c0b Bump version to 1.0 rc3 2014-07-24 13:25:43 -04:00
Roberto Rosario 502ec89d58 Add functional document API test 2014-07-24 12:33:52 -04:00
Roberto Rosario d2ae771d6a Make sure the reponse has a Content-Type
Before trying to make sure it is an HTML response
or else it can causes errors in DELETE API responses
2014-07-24 12:31:07 -04:00
Roberto Rosario a712f2e786 Exclude the API urls from forced session based authentication
We now have token based authentication support too
2014-07-24 11:38:20 -04:00
Roberto Rosario 3c4ddecf80 Enable token authentication for the API, add API token request view 2014-07-24 01:03:51 -04:00
Roberto Rosario 8807c52ac3 Merge remote-tracking branch 'origin/master' 2014-07-24 00:38:26 -04:00
Roberto Rosario 133eb2d094 Allow new document version to be created without having to specify the document 2014-07-24 00:37:52 -04:00
Roberto Rosario af445e9f3e Merge pull request #21 from audax/bugfix/sh-import
Fix import issues with the sh library
2014-07-23 21:41:55 -04:00
Jens Kadenbach 2e68dc5670 Added Jens Kadenbach to contributors 2014-07-23 22:49:49 +00:00