Skip to content
Snippets Groups Projects
Commit 9d96600b authored by Bryan BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

put primers_file in job model

parent d21e95a5
No related branches found
No related tags found
No related merge requests found
...@@ -58,15 +58,18 @@ class SimulatorDataForm(forms.Form): ...@@ -58,15 +58,18 @@ class SimulatorDataForm(forms.Form):
class PCRModelForm(forms.ModelForm): class PCRModelForm(forms.ModelForm):
class Meta: class Meta:
model = SimulatorJob model = SimulatorJob
fields = ('pcr_pairs_str',) fields = (
widgets = {'pcr_pairs_str': forms.Textarea(attrs={'rows': 2})} 'pcr_pairs_str',
'primers_file',
primers_file = forms.FileField( )
required=False, widgets = {'pcr_pairs_str': forms.Textarea(attrs={'rows': 2}), 'primers_file': forms.ClearableFileInput()}
label=_('Primers file'),
help_text=_('A CSV file where the header is \"primerId;sequence\".\nNote that the separator is \";\".'), # primers_file = forms.FileField(
# widget=forms.ClearableFileInput(attrs={'multiple': False}), # required=False,
) # label=_('Primers file'),
# help_text=_('A CSV file where the header is \"primerId;sequence\".\nNote that the separator is \";\".'),
# # widget=forms.ClearableFileInput(attrs={'multiple': False}),
# )
# def __init__(self, *args, **kwargs): # def __init__(self, *args, **kwargs):
# # files=kwargs.pop('files', dict()) # # files=kwargs.pop('files', dict())
......
# Generated by Django 5.1.8 on 2025-04-18 14:06
import assemblies.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assemblies', '0008_simulatorjob_pcr_pairs_str_and_more'),
]
operations = [
migrations.AddField(
model_name='simulatorjob',
name='primers_file',
field=models.FileField(
blank=True,
help_text='A CSV file where the header is "primerId;sequence".\nNote that the separator is ";".',
null=True,
upload_to='assemblies.models.job_dependant_primers_file_upload_to',
verbose_name='Primers file',
),
),
]
...@@ -257,6 +257,18 @@ class JobStatus(models.IntegerChoices): ...@@ -257,6 +257,18 @@ class JobStatus(models.IntegerChoices):
__empty__ = "(Unknown)" __empty__ = "(Unknown)"
class FixedFilenameJobDependantUploadTo:
def __init__(self, filename):
self.forced_filename = filename
def __call__(self, job, filename, *args, **kwargs):
return job.job_dir / self.forced_filename
def job_dependant_primers_file_upload_to(job, filename):
return (job.job_dir / insillyclo.main.DEFAULT_PCR_FILENAME).relative_to(settings.MEDIA_ROOT)
class SimulatorJob(models.Model): class SimulatorJob(models.Model):
######################################################################### #########################################################################
# Job attributs and parameters # Job attributs and parameters
...@@ -286,6 +298,19 @@ class SimulatorJob(models.Model): ...@@ -286,6 +298,19 @@ class SimulatorJob(models.Model):
help_text="In a CSV-like format where you have one pair per line, " help_text="In a CSV-like format where you have one pair per line, "
"the forward primer first, then the reverse primer.", "the forward primer first, then the reverse primer.",
) )
primers_file = models.FileField(
verbose_name=_('Primers file'),
help_text=_('A CSV file where the header is \"primerId;sequence\".\nNote that the separator is \";\".'),
blank=True,
null=True,
# upload_to=FixedFilenameJobDependantUploadTo(insillyclo.main.DEFAULT_PCR_FILENAME),
# upload_to=lambda o,f:o.run_dir/insillyclo.main.DEFAULT_PCR_FILENAME,
upload_to=job_dependant_primers_file_upload_to,
# validators=[
# FileExtensionValidator(['pdf']),
# FileMimeTypeValidator(['application/pdf']),
# ],
)
restriction_enzyme_gel = models.TextField( restriction_enzyme_gel = models.TextField(
default='', default='',
blank=True, blank=True,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment