Skip to content

Commit

Permalink
Merge pull request #16 from hell03end/stabilization
Browse files Browse the repository at this point in the history
Stabilization
  • Loading branch information
hell03end authored Feb 17, 2019
2 parents a4272a9 + badd568 commit 3bc0a69
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
12 changes: 7 additions & 5 deletions web_client.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{%- extends 'bootstrap/base.html' -%}
{%- import 'bootstrap/wtf.html' as wtf -%}
{%- import 'bootstrap/fixes.html' as fixes -%}

{%- block metas %}
{{super()}}
{{fixes.ie8()}}
{%- endblock metas %}

{%- block styles -%}
{{super()}}
Expand Down Expand Up @@ -64,14 +70,10 @@
role="button"
aria-haspopup="true"
aria-expanded="false">
{{"Target board type"}}
{{"Select target board type"}}
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li class="dropdown-header">
{{"Select board"}}
</li>
<li role="separator" class="divider"></li>
{%- for board in boards -%}
<li>
<a href="{{url_for('index', board=board)}}">
Expand Down
25 changes: 16 additions & 9 deletions web_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,20 @@ class BoardForm(FlaskForm):
)
conf = SelectMultipleField(
"Board configurations",
description="Use Ctrl + MouseClick to select multiple items",
validators=[Optional()],
id="board-form-enable-conf"
)
enable_mips = BooleanField(
"Include SchoolMIPS core to generated project",
default=False,
validators=[Optional()],
id="board-form-enable-mips"
)
mips = SelectField(
"Version of SchoolMIPS core",
choices=tuple((v, v) for v in MIPS.VERSIONS),
description="Version of SchoolMIPS core to include in project",
choices=[("", "none")] + [(v, v) for v in MIPS.VERSIONS],
validators=[Optional()],
id="board-form-mips"
)
func = SelectMultipleField(
"Additional functions",
description="Use Ctrl + MouseClick to select multiple items",
choices=tuple(FUNCTIONS.ITEMS.items()),
validators=[Optional()],
id="board-form-enable-func"
Expand All @@ -93,14 +90,24 @@ def validate_name(self, name: StringField) -> NoReturn:
logging.debug(f"Invalid project name '{name}'")
raise ValidationError(f"Invalid project name '{name}'")

def validate_mips(self, mips: StringField) -> NoReturn:
mips = mips.data.strip()
if mips and mips not in MIPS.VERSIONS:
logging.debug(f"Invalid mips type '{mips}'")
raise ValidationError(f"Invalid mips type '{mips}'")


class Config(object):
def __init__(self, board: str, form: BoardForm) -> NoReturn:
self.board = board
self.mips_type = form.mips.data if form.enable_mips.data else None
self.mips_type = None
if form.mips.data and form.mips.data in MIPS.VERSIONS:
self.mips_type = form.mips.data
self.project_name = form.name.data.strip()
self.configs = self._to_dict(form.conf.data)
self.functions = self._to_dict(form.func.data)
self.functions = self._to_dict(
tuple(filter(lambda x: x in FUNCTIONS.ITEMS, form.func.data))
)
self.functions_params = {} # TODO

@staticmethod
Expand Down

0 comments on commit 3bc0a69

Please sign in to comment.