Skip to content

Commit 14404f4

Browse files
authored
Merge pull request #17 from MeeGoIntegration/device-model-variant
Pass Device{Model,Variant} .ks headers along to mic via tokenmap
2 parents 581fa66 + 5bf39a9 commit 14404f4

3 files changed

Lines changed: 30 additions & 8 deletions

File tree

src/img_web/app/forms.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,25 +251,39 @@ class ImageJobForm(forms.Form):
251251
help_text=\
252252
"Packages: comma separated list of tags "\
253253
"to describe the image built.")
254-
254+
devicemodel = forms.CharField(
255+
label="Device model",
256+
required=False,
257+
widget=forms.HiddenInput(attrs={'readonly': 'readonly'}),
258+
)
259+
devicevariant = forms.CharField(
260+
label="Device variant",
261+
required=False,
262+
widget=forms.HiddenInput(attrs={'readonly': 'readonly'}),
263+
)
255264

256265
def __init__(self, *args, **kwargs):
257266
super(ImageJobForm, self).__init__(*args, **kwargs)
258267
self.fields['template'].choices = []
268+
suggested_re = re.compile(
269+
r'^#.*?Suggested(Architecture|ImageType|Features):(.*)$'
270+
)
271+
device_re = re.compile(
272+
r'^#.*?(DeviceModel|DeviceVariant):(.*)$'
273+
)
259274
for template in glob.glob(os.path.join(settings.TEMPLATESDIR, '*.ks')):
260275
name = os.path.basename(template)
261276
templatename = os.path.basename(template)
262277
attrs = {}
263278
with open(template, 'r') as tf:
264279
for line in tf:
265-
if re.match(r'^#.*?DisplayName:.+$', line):
280+
match = suggested_re.match(line) or device_re.match(line)
281+
if match:
282+
key = 'data-' + match.group(1).lower()
283+
val = match.group(2).strip()
284+
attrs[key] = val
285+
elif re.match(r'^#.*?DisplayName:.+$', line):
266286
name = line.split(":")[1].strip()
267-
if re.match(r'^#.*?SuggestedFeatures:.+$', line):
268-
attrs["data-features"] = line.split(":")[1].strip()
269-
if re.match(r'^#.*?SuggestedArchitecture:.+$', line):
270-
attrs["data-architecture"] = line.split(":")[1].strip()
271-
if re.match(r'^#.*?SuggestedImageType:.+$', line):
272-
attrs["data-imagetype"] = line.split(":")[1].strip()
273287

274288
self.fields['template'].choices.append((templatename , name, attrs))
275289

src/img_web/app/views.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ def submit(request):
150150
archtoken = "i586"
151151
tokenmap["ARCH"] = archtoken
152152

153+
devicemodeltoken = jobdata.get('devicemodel')
154+
if devicemodeltoken:
155+
tokenmap['DEVICEMODEL'] = devicemodeltoken
156+
devicevarianttoken = jobdata.get('devicevariant')
157+
if devicevarianttoken:
158+
tokenmap['DEVICEVARIANT'] = devicevarianttoken
159+
153160
tokens_list = []
154161
extra_repos_tmp = []
155162
for token, tokenvalue in tokenmap.items():

src/img_web/templates/app/upload.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
</td>
113113
</tr>
114114
</table>
115+
{{ jobform.devicemodel }} {{ jobform.devicevariant }}
115116
</fieldset>
116117
</table>
117118
<fieldset>

0 commit comments

Comments
 (0)