def manage_importer(self): # Do one look up for speed self.roles = Results2Dict(Roles.loadAll()) self.counties = Results2Dict(Counties.loadAll()) self.courts = Results2Dict(Courts.loadAll()) self.callnumbers = Results2Dict(CallNumbers.loadAll()) self.containers = Results2Dict(Containers.loadAll(order="container asc")) self.actiontypes = Results2Dict(ActionTypes.loadAll()) self.suffixs = Results2Dict(Suffixs.loadAll()) self.prefixs = Results2Dict(Prefixs.loadAll()) if "submit" in self.request.params: # case_override = json.loads(self.request.params.get('case.override','{}')) # entity_override = json.loads(self.request.params.get('entity.override','{}')) entities = self.request.POST["entities"].file entities_fields = self.request.params.get("entity.fields").split(",") cases = self.request.POST["cases"].file case_fields = self.request.params.get("case.fields").split(",") archive_id = self.request.params.get("archive", 0) print "CREATING CASES --------------" cases_id_map = self.createCases_returnMap(cases, case_fields, archive_id) print "CREATING ENTITIES ----------------" fix = self.request.params.get("firstname.fix", "0") == "1" self.createEntitiesCleanup(entities, entities_fields, cases_id_map, fix) # else: # self.createEntities(entities,entities_fields,cases_id_map) self.set("archives", Archives.loadAll(order="name asc")) self.set("containers", self.containers) self.set("callnumbers", self.callnumbers) return self.response
def manage_records(self): case_id = self.request.matchdict['case_id'] if case_id != 'new': case_id = int(case_id) # Add last entry for new entries self.set('lastentry',case_id) lastcase = Cases.load(order='id desc') if lastcase: self.set('lastentry',lastcase.id) # Handle Saving if 'edit.Form.submit.save' in self.request.params or 'edit.Form.submit.savenext' in self.request.params: self._save(case_id) if 'edit.Form.submit.savenext' in self.request.params: return HTTPFound(location=route_url('manage_records', self.request, case_id='new')) return HTTPFound(location=route_url('manage_records', self.request, case_id=case_id)) # Handle Loading Information on screen if case_id == 'new' or case_id == 0: case = None else: case = DBSession.query(Cases,Counties,ActionTypes,Archives).filter(Cases.id == case_id) \ .filter(Cases.actiontype == ActionTypes.id) \ .filter(Cases.county == Counties.id) \ .filter(Cases.archive == Archives.id) \ .first() entities = [] if case_id != 'new': entities = DBSession.query(Entities,Roles).filter(Entities.case_id == case_id) \ .filter(Entities.role == Roles.id) \ .order_by('entity asc').all() self.set('case',case) self.set('year',self._get_year) self.set('case_id',case_id) self.set('entities',entities) self.set('actiontypes',ActionTypes.loadAll(order="actiontype asc")) self.set('containers',Containers.loadAll(order="container asc")) self.set('courts',Courts.loadAll(order="court asc")) self.set('call_numbers',CallNumbers.loadAll(order="call_number asc")) self.set('archives',Archives.loadAll(order="name asc")) self.set('roles',Roles.loadAll(order="role asc")) self.set('counties',Counties.loadAll(order="county asc")) self.set('prefixs',Prefixs.loadAll(order="prefix asc")) self.set('suffixs',Suffixs.loadAll(order="suffix asc")) #${request.application_url}/manage/data/Entities/delete/${entity.Entities.id}?back=${request.url} delete_url = '' if case: entity_base_url = self.request.application_url + '/manage/data/Entities/delete/' case_base_url = self.request.application_url + '/manage/data/Cases/delete/' delete_url = case_base_url + str(case.Cases.id) + '?back=' for e in entities: delete_url += entity_base_url + str(e.Entities.id) + '?back=' delete_url += self.request.application_url + '/manage/cases' # Back to base self.set('delete_url', delete_url) return self.response