Пример #1
0
 def create_person(self, post_data):
     """ creates a person item into a project
     """
     ok = True
     required_params = ['source_id',
                        'item_type',
                        'foaf_type',
                        'combined_name',
                        'given_name',
                        'surname',
                        'mid_init',
                        'initials']
     for r_param in required_params:
         if r_param not in post_data:
             # we're missing some required data
             # don't create the item
             ok = False
             message = 'Missing paramater: ' + r_param + ''
             self.errors.append(message)
     uuid = self.create_or_validate_uuid(post_data)
     if uuid is False:
         ok = False
         note = '; '.join(self.errors)
     if ok:
         label = post_data['combined_name']
         new_pers = Person()
         new_pers.uuid = uuid
         new_pers.project_uuid = self.project_uuid
         new_pers.source_id = post_data['source_id']
         new_pers.foaf_type = post_data['foaf_type']
         new_pers.combined_name = post_data['combined_name']
         new_pers.given_name = post_data['given_name']
         new_pers.surname = post_data['surname']
         new_pers.mid_init = post_data['mid_init']
         new_pers.initials = post_data['initials']
         new_pers.save()
         new_man = Manifest()
         new_man.uuid = uuid
         new_man.project_uuid = self.project_uuid
         new_man.source_id = post_data['source_id']
         new_man.item_type = 'persons'
         new_man.repo = ''
         new_man.class_uri = post_data['foaf_type']
         new_man.label = post_data['combined_name']
         new_man.des_predicate_uuid = ''
         new_man.views = 0
         new_man.save()
         self.created_uuid = uuid
     else:
         label = '[Item not created]'
         uuid = False
     if ok:
         # now clear the cache a change was made
         self.clear_caches()
     self.response = {'action': 'create-item-into',
                      'ok': ok,
                      'change': {'uuid': uuid,
                                 'label': label,
                                 'note': self.add_creation_note(ok)}}
     return self.response
Пример #2
0
 def create_person(self, post_data):
     """ creates a person item into a project
     """
     ok = True
     required_params = [
         'source_id', 'item_type', 'foaf_type', 'combined_name',
         'given_name', 'surname', 'mid_init', 'initials'
     ]
     for r_param in required_params:
         if r_param not in post_data:
             # we're missing some required data
             # don't create the item
             ok = False
             message = 'Missing paramater: ' + r_param + ''
             self.errors.append(message)
     uuid = self.create_or_validate_uuid(post_data)
     if uuid is False:
         ok = False
         note = '; '.join(self.errors)
     if ok:
         label = post_data['combined_name']
         new_pers = Person()
         new_pers.uuid = uuid
         new_pers.project_uuid = self.project_uuid
         new_pers.source_id = post_data['source_id']
         new_pers.foaf_type = post_data['foaf_type']
         new_pers.combined_name = post_data['combined_name']
         new_pers.given_name = post_data['given_name']
         new_pers.surname = post_data['surname']
         new_pers.mid_init = post_data['mid_init']
         new_pers.initials = post_data['initials']
         new_pers.save()
         new_man = Manifest()
         new_man.uuid = uuid
         new_man.project_uuid = self.project_uuid
         new_man.source_id = post_data['source_id']
         new_man.item_type = 'persons'
         new_man.repo = ''
         new_man.class_uri = post_data['foaf_type']
         new_man.label = post_data['combined_name']
         new_man.des_predicate_uuid = ''
         new_man.views = 0
         new_man.save()
         self.created_uuid = uuid
     else:
         label = '[Item not created]'
         uuid = False
     if ok:
         # now clear the cache a change was made
         self.clear_caches()
     self.response = {
         'action': 'create-item-into',
         'ok': ok,
         'change': {
             'uuid': uuid,
             'label': label,
             'note': self.add_creation_note(ok)
         }
     }
     return self.response
Пример #3
0
 def create_person_item(self):
     """ Create and save a new subject object"""
     new_pers = Person()
     new_pers.uuid = self.uuid  # use the previously assigned temporary UUID
     new_pers.project_uuid = self.project_uuid
     new_pers.source_id = self.source_id
     new_pers.foaf_type = self.foaf_type
     new_pers.combined_name = self.combined_name
     new_pers.given_name = self.given_name
     new_pers.surname = self.surname
     new_pers.mid_init = self.mid_init
     new_pers.initials = self.initials
     new_pers.save()
     new_man = Manifest()
     new_man.uuid = self.uuid
     new_man.project_uuid = self.project_uuid
     new_man.source_id = self.source_id
     new_man.item_type = 'persons'
     new_man.repo = ''
     new_man.class_uri = self.foaf_type
     new_man.label = self.label
     new_man.des_predicate_uuid = ''
     new_man.views = 0
     new_man.save()
Пример #4
0
 def create_person_item(self):
     """ Create and save a new subject object"""
     new_pers = Person()
     new_pers.uuid = self.uuid  # use the previously assigned temporary UUID
     new_pers.project_uuid = self.project_uuid
     new_pers.source_id = self.source_id
     new_pers.foaf_type = self.foaf_type
     new_pers.combined_name = self.combined_name
     new_pers.given_name = self.given_name
     new_pers.surname = self.surname
     new_pers.mid_init = self.mid_init
     new_pers.initials = self.initials
     new_pers.save()
     new_man = Manifest()
     new_man.uuid = self.uuid
     new_man.project_uuid = self.project_uuid
     new_man.source_id = self.source_id
     new_man.item_type = 'persons'
     new_man.repo = ''
     new_man.class_uri = self.foaf_type
     new_man.label = self.label
     new_man.des_predicate_uuid = ''
     new_man.views = 0
     new_man.save()