def generate_copo_publications_data(profile_id): # This method generates the 'json' for building the UI table p = Publication(profile_id) publications = p.get_all_publications() columns = [] dataSet = [] # headers for el in p.schema: columns.append({"title": el.label}) columns.append({"title": " "}) # extra 'blank' header for record actions column # data for pb in publications: row = get_record_data(pb, p.schema) dataSet.append(row) # define action buttons for the table. ALWAYS include the class 'copo-dt' in className!!! action_buttons = [ {'text': 'Edit', 'className': 'copo-dt btn btn-success', 'iconClass': 'fa fa-pencil-square-o'}, {'text': 'Delete', 'className': 'copo-dt btn btn-danger', 'iconClass': 'fa fa-trash-o'} ] return {"columns": columns, "dataSet": dataSet, "table_id": "publication_table", "action_buttons": action_buttons}
def publications_tests(self): auto_fields = { "copo.publication.title": "Test Title", "copo.publication.authorList": "Author1 T1,Author2 T2,Author3 T3", "": "", "copo.publication.doi": "12345", "copo.publication.pubMedID": "12345", "copo.publication.status.annotationValue": "PubMed - indexed for MEDLINE", "copo.publication.status.termSource": "xyz", "copo.publication.status.termAccession": "xyz", "copo.publication.created_on": "01:01:2000", "copo.publication.comments": "no comments"} auto_fields = json.dumps(auto_fields) task = 'save' # set session variable s = self.client.session s['profile_id'] = str(self.profile_id) s.save() # call view response = self.client.post(reverse('copo:edit_publication'), {'auto_fields': auto_fields, 'task': task}) # check responses plist = Publication(self.profile_id).get_all_pubs_in_profile() self.assertEqual(plist.count(), 1, 'Wrong number of Publications found, should be one.') self.assertEqual(response.status_code, 200, 'Publications test failed to return status 200.')