Changeset 3219


Ignore:
Timestamp:
25 Feb 2008, 12:40:14 (17 years ago)
Author:
joachim
Message:

check if required fields are present in data-record

Location:
WAeUP_SRP/base
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/WAeUPImport.py

    r3208 r3219  
    104104        for widget in self.layout.keys():
    105105            self.validators[widget] = self.layout[widget].validate
     106        self.required_keys = {}
     107        for mode in self.required_modes:
     108            self.required_keys[mode] = [self.layout.getIdUnprefixed(id)
     109                                for id,widget in self.layout.objectItems()
     110                                if widget.is_required]
    106111        self.init_errors = ','.join(errors)
    107112
     
    279284    plural_name = "%ss" % name
    280285    commit_after = 1000000
     286    required_modes = ('create','edit')
    281287
    282288    def getStudentRecord(self,mapping): ###(
     
    405411    plural_name = "%ss" % name
    406412    commit_after = 100000
     413    required_modes = ('create','edit')
    407414
    408415    def create(self,mapping):
  • WAeUP_SRP/base/WAeUPTool.py

    r3205 r3219  
    1 #-*- mode: python; mode: fold -*-
     1# -*- mode: python; mode: fold; -*-
    22# (C) Copyright 2005 The WAeUP group  <http://www.waeup.org>
    33# Author: Joachim Schmitz (js@aixtraware.de)
     
    14401440            msg = 'not ignorable key(s): "%s" found in heading' % ", ".join(diff2schema)
    14411441            return msg
    1442         # if import_mode in importer.required_modes:
    1443         #     required_keys = [importer.layout.getIdUnprefixed(id)
    1444         #                         for id,widget in importer.layout.objectItems()
    1445         #                         if widget.is_required]
    1446         #     if not set(required_keys).issubset(set(import_keys)):
    1447         #         diff2import = set(required_keys).difference(set(import_keys))
    1448         #         msg = 'required key(s): "%s" not found in heading' % ", ".join(diff2import)
    1449         #         return msg
    14501442        #
    14511443        # start importing
     
    14861478            total += 1
    14871479            import_mode = item.get('import_mode','edit')
     1480            if (import_mode in importer.required_modes and
     1481                not set(importer.required_keys[import_mode]).issubset(set(import_keys))):
     1482                diff2import = set(importer.required_keys[import_mode]).difference(set(import_keys))
     1483                error_string += 'required key(s): "%s" not found in heading' % ", ".join(diff2import)
    14881484            import_method = getattr(importer, '%(import_mode)s' % vars(),None )
    14891485            if import_method is None:
  • WAeUP_SRP/base/Widgets.py

    r3200 r3219  
    444444            datastructure.setError(widget_id, "'%s' not a valid level" % v)
    445445            return 0
    446         if self.is_required and not len(v):
    447             datastructure.setError(widget_id, "level key required")
    448             return 0
     446        # if self.is_required and len(v) == 0:
     447        #     datastructure.setError(widget_id, "level key required")
     448        #     return 0
    449449
    450450        datamodel = datastructure.getDataModel()
     
    519519            datastructure.setError(widget_id, "'%s' not a valid verdict key" % v)
    520520            return 0
    521         if self.is_required and not len(v):
    522             datastructure.setError(widget_id, "verdict required")
    523             return 0
     521        # if self.is_required and not len(v):
     522        #     datastructure.setError(widget_id, "verdict required")
     523        #     return 0
    524524
    525525        datamodel = datastructure.getDataModel()
Note: See TracChangeset for help on using the changeset viewer.