Remember selected iso when loading samples
This commit is contained in:
parent
3c4c8e6da2
commit
b71845f83a
|
@ -30,7 +30,7 @@
|
||||||
<legend>Base ISO:</legend>
|
<legend>Base ISO:</legend>
|
||||||
<select name="base_image" class="c-select">
|
<select name="base_image" class="c-select">
|
||||||
{% for iso in ISOS: %}
|
{% for iso in ISOS: %}
|
||||||
<option value="{{ iso }}">{{ iso }}</option>
|
<option value="{{ iso }}"{% if BASE_IMAGE == iso %} selected{% endif %}>{{ iso }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
<legend>Sample configs:</legend>
|
<legend>Sample configs:</legend>
|
||||||
<select name="sample" class="c-select">
|
<select name="sample" class="c-select">
|
||||||
{% for sample in SAMPLES: %}
|
{% for sample in SAMPLES: %}
|
||||||
<option value="{{ sample }}"{% if current_sample == sample %} selected{% endif %}>{{ sample }}</option>
|
<option value="{{ sample }}"{% if CURRENT_SAMPLE == sample %} selected{% endif %}>{{ sample }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" value="Load" name="action" class="btn btn-warning" onclick="if(fields_dirty){return confirm('Warning: loading a new template will abandon changes made below.')}; return true">
|
<input type="submit" value="Load" name="action" class="btn btn-warning" onclick="if(fields_dirty){return confirm('Warning: loading a new template will abandon changes made below.')}; return true">
|
||||||
|
|
25
main.py
25
main.py
|
@ -35,29 +35,31 @@ class ISOserver(object):
|
||||||
self.samples[item]["SAMPLE_INFO"] = f.read()
|
self.samples[item]["SAMPLE_INFO"] = f.read()
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def index(self, refresh=False, sample="default"):
|
def index(self, refresh=False, sample="default", base_image=""):
|
||||||
if refresh or "REFRESH" in os.environ:
|
if refresh or "REFRESH" in os.environ:
|
||||||
self._load_templates()
|
self._load_templates()
|
||||||
|
|
||||||
yield(self.template.render(ISOS=self.iso_selection,
|
yield(self.template.render(ISOS=self.iso_selection,
|
||||||
SAMPLES=self.samples.keys(),
|
SAMPLES=self.samples.keys(),
|
||||||
current_sample=sample,
|
CURRENT_SAMPLE=sample,
|
||||||
|
BASE_IMAGE=base_image,
|
||||||
**self.samples[sample]))
|
**self.samples[sample]))
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def process(self, menu_entries, seed_content, kickstart, base_image, action, sample):
|
def process(self, menu_entries, seed_content, kickstart, base_image, action, sample):
|
||||||
if action == "Load":
|
|
||||||
assert sample in self.samples.keys()
|
|
||||||
raise cherrypy.HTTPRedirect("/?sample={}".format(sample))
|
|
||||||
|
|
||||||
assert base_image in self.iso_selection
|
assert base_image in self.iso_selection
|
||||||
|
|
||||||
cherrypy.response.headers['Content-Type'] = 'application/octet-stream'
|
if action == "Load":
|
||||||
cherrypy.response.headers['Content-Description'] = 'File Transfer'
|
assert sample in self.samples.keys()
|
||||||
cherrypy.response.headers['Content-Disposition'] = 'attachment; filename="{}-custom.iso"'.format(base_image)
|
raise cherrypy.HTTPRedirect("/?base_image={}&sample={}".format(base_image, sample))
|
||||||
|
|
||||||
builder = self.isoBuilder(menu_entries, seed_content, kickstart, base_image)
|
elif action == "Build":
|
||||||
return builder()
|
cherrypy.response.headers['Content-Type'] = 'application/octet-stream'
|
||||||
|
cherrypy.response.headers['Content-Description'] = 'File Transfer'
|
||||||
|
cherrypy.response.headers['Content-Disposition'] = 'attachment; filename="{}-custom.iso"'.format(base_image)
|
||||||
|
|
||||||
|
builder = self.isoBuilder(menu_entries, seed_content, kickstart, base_image)
|
||||||
|
return builder()
|
||||||
process._cp_config = {'response.stream': True}
|
process._cp_config = {'response.stream': True}
|
||||||
|
|
||||||
def isoBuilder(self, menu_entries, seed_content, kickstart, base_image):
|
def isoBuilder(self, menu_entries, seed_content, kickstart, base_image):
|
||||||
|
@ -89,7 +91,6 @@ class ISOserver(object):
|
||||||
else:
|
else:
|
||||||
self.builder_semaphores[base_image].release()
|
self.builder_semaphores[base_image].release()
|
||||||
|
|
||||||
print("Done!")
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue