diff --git a/src/img_web/app/forms.py b/src/img_web/app/forms.py index 375b84f..093fa6b 100644 --- a/src/img_web/app/forms.py +++ b/src/img_web/app/forms.py @@ -251,7 +251,16 @@ class ImageJobForm(forms.Form): help_text=\ "Packages: comma separated list of tags "\ "to describe the image built.") - + devicemodel = forms.CharField( + label="Device model", + required=False, + widget=forms.TextInput(attrs={'readonly': 'readonly'}), + ) + devicevariant = forms.CharField( + label="Device variant", + required=False, + widget=forms.TextInput(attrs={'readonly': 'readonly'}), + ) def __init__(self, *args, **kwargs): super(ImageJobForm, self).__init__(*args, **kwargs) @@ -262,14 +271,17 @@ def __init__(self, *args, **kwargs): attrs = {} with open(template, 'r') as tf: for line in tf: - if re.match(r'^#.*?DisplayName:.+$', line): + match = re.match(r'^#.*?Suggested([^:]*):(.*)$', line) + if match: + key = 'data-' + match.group(1).lower() + val = match.group(2).strip() + attrs[key] = val + elif re.match(r'^#.*?DisplayName:.+$', line): name = line.split(":")[1].strip() - if re.match(r'^#.*?SuggestedFeatures:.+$', line): - attrs["data-features"] = line.split(":")[1].strip() - if re.match(r'^#.*?SuggestedArchitecture:.+$', line): - attrs["data-architecture"] = line.split(":")[1].strip() - if re.match(r'^#.*?SuggestedImageType:.+$', line): - attrs["data-imagetype"] = line.split(":")[1].strip() + elif re.match(r'^#.*?DeviceModel:.+$', line): + attrs['data-devicemodel'] = line.split(":")[1].strip() + elif re.match(r'^#.*?DeviceVariant:.+$', line): + attrs['data-devicevariant'] = line.split(":")[1].strip() self.fields['template'].choices.append((templatename , name, attrs)) diff --git a/src/img_web/app/views.py b/src/img_web/app/views.py index 6a99a9e..6fc31da 100644 --- a/src/img_web/app/views.py +++ b/src/img_web/app/views.py @@ -150,6 +150,13 @@ def submit(request): archtoken = "i586" tokenmap["ARCH"] = archtoken + devicemodeltoken = jobdata.get('devicemodel') + if devicemodeltoken: + tokenmap['DEVICEMODEL'] = devicemodeltoken + devicevarianttoken = jobdata.get('devicevariant') + if devicevarianttoken: + tokenmap['DEVICEVARIANT'] = devicevarianttoken + tokens_list = [] extra_repos_tmp = [] for token, tokenvalue in tokenmap.items(): diff --git a/src/img_web/templates/app/upload.html b/src/img_web/templates/app/upload.html index b7063e0..db2e12a 100644 --- a/src/img_web/templates/app/upload.html +++ b/src/img_web/templates/app/upload.html @@ -111,6 +111,22 @@ {{ jobform.architecture }} + + + {{ jobform.devicemodel.label_tag }} + + + {{ jobform.devicemodel }} + + + + + {{ jobform.devicevariant.label_tag }} + + + {{ jobform.devicevariant }} + +