3434 FASTQ = ['barcodes' , 'forward seqs' , 'reverse seqs' ])
3535
3636
37- def get_accessible_raw_data (user ):
37+ def _get_accessible_raw_data (user ):
3838 """Retrieves a tuple of raw_data_id and the last study title for that
3939 raw_data
4040 """
@@ -45,34 +45,35 @@ def get_accessible_raw_data(user):
4545 return d
4646
4747
48- def get_raw_data (rdis ):
49- """Get all raw data objects from a list of raw_data_ids"""
50- return [RawData (rdi ) for rdi in rdis ]
51-
52-
53- def get_prep_templates (pt_ids ):
54- """Get all the prep template objects from a list of ids
48+ def _template_generator (study , full_access ):
49+ """Generates tuples of prep template information
5550
5651 Parameters
5752 ----------
58- pt_ids : list of int
59- The prep template ids
53+ study : Study
54+ The study to get all the prep templates
55+ full_access : boolean
56+ A boolean that indicates if the user has full access to the study
6057
6158 Returns
6259 -------
63- list of PrepTemplate
60+ Generator of tuples of (int, str, PrepTemplate, (str, str, str))
61+ Each tuple contains the prep template id, the prep template data_type
62+ the PrepTemplate object and a tuple with 3 strings for the style of
63+ the prep template status icons
6464 """
65- return [PrepTemplate (pt_id ) for pt_id in sorted (pt_ids )]
65+ for pt_id in study .prep_templates ():
66+ pt = PrepTemplate (pt_id )
67+ if full_access or pt .status () == 'public' :
68+ yield (pt .id , pt .data_type (), pt , STATUS_STYLER [pt .status ])
6669
6770
6871class PrepTemplateTab (BaseUIModule ):
6972 def render (self , study , full_access ):
7073 files = [f for _ , f in get_files_from_uploads_folders (str (study .id ))]
7174 data_types = sorted (viewitems (get_data_types ()), key = itemgetter (1 ))
7275 prep_templates_info = [
73- (pt .id , pt .data_type (), pt , STATUS_STYLER [pt .status ])
74- for pt in get_prep_templates (study .prep_templates ())
75- if full_access or pt .status () == 'public' ]
76+ res for res in _template_generator (study , full_access )]
7677 # Get all the ENA terms for the investigation type
7778 ontology = Ontology (convert_to_id ('ENA' , 'ontology' ))
7879 # make "Other" show at the bottom of the drop down menu
@@ -143,9 +144,9 @@ def render(self, study, prep_template, full_access, ena_terms,
143144 files = [f for _ , f in get_files_from_uploads_folders (str (study .id ))]
144145
145146 other_studies_rd = sorted (viewitems (
146- get_accessible_raw_data (user )))
147+ _get_accessible_raw_data (user )))
147148
148- # A prep template can be modified if it's status is sanbdox
149+ # A prep template can be modified if its status is sanbdox
149150 is_editable = prep_template .status == 'sanbdox'
150151
151152 raw_data_id = prep_template .raw_data
0 commit comments