@@ -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
0 commit comments