Ignore:
Timestamp:
21 May 2019, 08:02:51 (6 years ago)
Author:
Henrik Bettermann
Message:

Backup deleted graduated student data somewhere else to ease graduated student data migration.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/datacenter.py

    r14680 r15416  
    5858        """Create standard subdirs.
    5959        """
    60         for name in ['finished', 'unfinished', 'logs', 'deleted']:
     60        for name in ['finished', 'graduated', 'unfinished', 'logs', 'deleted']:
    6161            path = os.path.join(self.storage, name)
    6262            if os.path.exists(path):
     
    6767    @property
    6868    def deleted_path(self):
    69         """Get the path for deleted object data.
     69        """Get the path for deleted student data.
    7070        """
    7171        return os.path.join(self.storage, 'deleted')
     72
     73    @property
     74    def graduated_path(self):
     75        """Get the path for deleted graduated student data.
     76        """
     77        return os.path.join(self.storage, 'graduated')
    7278
    7379    def getPendingFiles(self, sort='name'):
  • main/waeup.kofa/trunk/src/waeup/kofa/doctests/batchprocessing_browser.txt

    r13872 r15416  
    644644
    645645    >>> sorted(os.listdir(dc_path))
    646     ['deleted', 'finished', 'logs', 'unfinished', 'users_zope.mgr.create.pending.csv']
     646    ['deleted', 'finished', 'graduated', 'logs', 'unfinished', 'users_zope.mgr.create.pending.csv']
    647647
    648648    >>> os.listdir(dc_path + '/unfinished')
  • main/waeup.kofa/trunk/src/waeup/kofa/doctests/datacenter.txt

    r12948 r15416  
    2323    '/tmp/tmp...'
    2424
    25 Beside other things it provides a location to put data of deleted
     25Beside other things it provides two locations to put data of deleted
    2626items into:
    2727
     
    2929    >>> del_path = mydatacenter.deleted_path
    3030    >>> os.path.isdir(del_path)
     31    True
     32    >>> grad_path = mydatacenter.graduated_path
     33    >>> os.path.isdir(grad_path)
    3134    True
    3235
     
    163166    ...                            pending_src, mode='create')
    164167    >>> sorted(os.listdir(dc_root))
    165     ['deleted', 'finished', 'logs', 'unfinished']
     168    ['deleted', 'finished', 'graduated', 'logs', 'unfinished']
    166169
    167170    >>> sorted(os.listdir(fin_dir))
     
    188191    ...                                 pending_src, mode='create')
    189192    >>> sorted(os.listdir(dc_root))
    190     ['deleted', 'finished', 'logs', 'mysource.create.pending.csv', 'unfinished']
     193    ['deleted', 'finished', 'graduated', 'logs', 'mysource.create.pending.csv', 'unfinished']
    191194
    192195    >>> sorted(os.listdir(fin_dir))
     
    209212
    210213    >>> sorted(os.listdir(dc_root))
    211     ['deleted', 'finished', 'logs', 'unfinished']
     214    ['deleted', 'finished', 'graduated', 'logs', 'unfinished']
    212215
    213216    >>> sorted(os.listdir(fin_dir))
     
    245248
    246249    >>> sorted(os.listdir(dc_root))
    247     ['deleted', 'finished', 'logs', 'mysource.create.pending.csv', 'unfinished']
     250    ['deleted', 'finished', 'graduated', 'logs', 'mysource.create.pending.csv', 'unfinished']
    248251
    249252    >>> sorted(os.listdir(fin_dir))
     
    261264
    262265    >>> sorted(os.listdir(dc_root))
    263     ['deleted', 'finished', 'logs', 'unfinished']
     266    ['deleted', 'finished', 'graduated', 'logs', 'unfinished']
    264267
    265268    >>> sorted(os.listdir(fin_dir))
  • main/waeup.kofa/trunk/src/waeup/kofa/doctests/pages.txt

    r15286 r15416  
    12201220
    12211221  >>> sorted(os.listdir(uploadpath))
    1222   ['deleted', 'finished', 'logs', 'unfinished']
     1222  ['deleted', 'finished', 'graduated', 'logs', 'unfinished']
    12231223
    12241224
     
    12611261
    12621262  >>> sorted(os.listdir(uploadpath))
    1263   ['deleted', 'finished', 'logs', 'myfaculties_zope.mgr.csv', 'unfinished']
     1263  ['deleted', 'finished', 'graduated', 'logs', 'myfaculties_zope.mgr.csv', 'unfinished']
    12641264
    12651265We create and upload also a CSV file containing departments:
  • main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py

    r15287 r15416  
    929929
    930930    deleted_path = schema.Bytes(
    931         title = u'Path were data about deleted objects should be stored.'
     931        title = u'Path for deleted student data.'
     932        )
     933
     934    graduated_path = schema.Bytes(
     935        title = u'Path for deleted graduated student data.'
    932936        )
    933937
  • main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py

    r15203 r15416  
    652652    `ticket_session` is an additional attribute which can be used to store the
    653653    session of the course when it was taken. Usually this information is
    654     redundantbecause the the parent study level object already contains this
     654    redundant because the the parent study level object already contains this
    655655    information except for the study level zero container which can be used to
    656656    store 'orphaned' course tickets.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/student.py

    r15163 r15416  
    486486    del_dir = site['datacenter'].deleted_path
    487487
     488    if student.state == GRADUATED:
     489        del_dir = site['datacenter'].graduated_path
     490
    488491    # save files of the student
    489492    move_student_files(student, del_dir)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_student.py

    r13314 r15416  
    3030from zope.interface import verify
    3131from zope.schema.interfaces import RequiredMissing
     32from hurry.workflow.interfaces import IWorkflowState
    3233from waeup.kofa.interfaces import IExtFileStore, IFileStoreNameChooser
    3334from waeup.kofa.students.student import (
     
    180181            del_dir, 'media', 'students', '00110', 'A111111',
    181182            'passport_A111111.jpg')
    182 
    183183        # The image was copied over
    184184        self.assertTrue(os.path.isfile(del_img_path))
     
    186186            open(del_img_path, 'rb').read(),
    187187            self.image_contents)
    188 
    189188        # The student data were put into CSV files
    190189        STUDENT_BACKUP_EXPORTER_NAMES = getUtility(
    191190            IStudentsUtils).STUDENT_BACKUP_EXPORTER_NAMES
    192 
     191        for name in STUDENT_BACKUP_EXPORTER_NAMES:
     192            csv_path = os.path.join(del_dir, '%s.csv' % name)
     193            self.assertTrue(os.path.isfile(csv_path))
     194            contents = open(csv_path, 'rb').read().split('\r\n')
     195            # We expect 3 lines output including a linebreak at end of file.
     196            self.assertEqual(len(contents), 3)
     197        return
     198
     199    def test_backup_single_graduated_data(self):
     200        # when a single graduated student is removed, the data is backed up
     201        # somewhere else
     202        self.setup_student(self.student)
     203        IWorkflowState(self.student).setState('graduated')
     204        # Add a fake image
     205        self.create_passport_img(self.student)
     206        handle_student_removed(self.student, None)
     207        del_dir = self.app['datacenter'].graduated_path
     208        del_img_path = os.path.join(
     209            del_dir, 'media', 'students', '00110', 'A111111',
     210            'passport_A111111.jpg')
     211        # The image was copied over
     212        self.assertTrue(os.path.isfile(del_img_path))
     213        self.assertEqual(
     214            open(del_img_path, 'rb').read(),
     215            self.image_contents)
     216        # The student data were put into CSV files
     217        STUDENT_BACKUP_EXPORTER_NAMES = getUtility(
     218            IStudentsUtils).STUDENT_BACKUP_EXPORTER_NAMES
    193219        for name in STUDENT_BACKUP_EXPORTER_NAMES:
    194220            csv_path = os.path.join(del_dir, '%s.csv' % name)
Note: See TracChangeset for help on using the changeset viewer.