@@ -130,8 +130,7 @@ def __init__(self, *args, **kwargs):
130130 name_field .help_text = "The unique name of your project."
131131
132132 def clean_name (self ):
133- name = self .cleaned_data ["name" ]
134- return " " .join (name .split ())
133+ return " " .join (self .cleaned_data ["name" ].split ())
135134
136135 def save (self , * args , ** kwargs ):
137136 project = super ().save (* args , ** kwargs )
@@ -282,3 +281,45 @@ def update_project_settings(self, project):
282281 }
283282 project .settings .update (config )
284283 project .save (update_fields = ["settings" ])
284+
285+
286+ class ProjectCloneForm (forms .Form ):
287+ clone_name = forms .CharField (widget = forms .TextInput (attrs = {"class" : "input" }))
288+ copy_inputs = forms .BooleanField (
289+ initial = True ,
290+ required = False ,
291+ help_text = "Input files located in the input/ work directory will be copied." ,
292+ widget = forms .CheckboxInput (attrs = {"class" : "checkbox mr-1" }),
293+ )
294+ copy_pipelines = forms .BooleanField (
295+ initial = True ,
296+ required = False ,
297+ help_text = "All pipelines assigned to the original project will be copied over." ,
298+ widget = forms .CheckboxInput (attrs = {"class" : "checkbox mr-1" }),
299+ )
300+ copy_settings = forms .BooleanField (
301+ initial = True ,
302+ required = False ,
303+ help_text = "All project settings will be copied." ,
304+ widget = forms .CheckboxInput (attrs = {"class" : "checkbox mr-1" }),
305+ )
306+ execute_now = forms .BooleanField (
307+ label = "Execute copied pipeline(s) now" ,
308+ initial = False ,
309+ required = False ,
310+ help_text = "Copied pipelines will be directly executed." ,
311+ )
312+
313+ def __init__ (self , instance , * args , ** kwargs ):
314+ self .project = instance
315+ super ().__init__ (* args , ** kwargs )
316+ self .fields ["clone_name" ].initial = f"{ self .project .name } clone"
317+
318+ def clean_clone_name (self ):
319+ clone_name = self .cleaned_data .get ("clone_name" )
320+ if Project .objects .filter (name = clone_name ).exists ():
321+ raise ValidationError ("Project with this name already exists." )
322+ return clone_name
323+
324+ def save (self , * args , ** kwargs ):
325+ return self .project .clone (** self .cleaned_data )
0 commit comments