-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from NLP4ALL/feature/50-organise-views-into-di…
…rectories Changed my mind, now even easier!
- Loading branch information
Showing
21 changed files
with
93 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""For providing a base controller for all controllers to inherit from.""" # pylint: disable=invalid-name | ||
|
||
import typing as t | ||
from flask import Blueprint, render_template | ||
|
||
class BaseController: # pylint: disable=too-few-public-methods | ||
"""Base controller for all controllers to inherit from.""" | ||
|
||
view_subdir = None | ||
blueprint: Blueprint | ||
|
||
@classmethod | ||
def render_template(cls, template_name: str, **context: t.Any) -> str: | ||
"""Render a template, wraps flask render to easily organize views.""" | ||
if cls.view_subdir: | ||
return render_template(cls.view_subdir + '/' + template_name, **context) | ||
raise TypeError("No view_subdir set for this controller") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
"""Data sources.""" # pylint: disable=invalid-name | ||
|
||
# @todo: SKELETON, NOT IMPLEMENTED | ||
from flask import redirect, render_template, url_for | ||
from flask import redirect, url_for | ||
|
||
from .BaseController import BaseController | ||
|
||
class DataSourceController: # pylint: disable=too-few-public-methods | ||
class DataSourceController(BaseController): # pylint: disable=too-few-public-methods | ||
"""Data Source Controller""" | ||
|
||
view_subdir = "datasource" | ||
|
||
@classmethod | ||
def home(cls): | ||
"""List of prepared data source""" | ||
return render_template("datasource/data_source_list.html", title="My Data Sources") | ||
return cls.render_template("data_source_list.html", title="My Data Sources") | ||
|
||
@classmethod | ||
def create(cls): | ||
"""Upload / create page""" | ||
return render_template("datasource/create_data_source.html", title="New Data Source") | ||
return cls.render_template("create_data_source.html", title="New Data Source") | ||
@classmethod | ||
def configure(cls): | ||
"""Specify data fields""" | ||
return render_template( | ||
"datasource/configure_data_source.html", | ||
return cls.render_template( | ||
"configure_data_source.html", | ||
title="Configure Data Source" | ||
) | ||
|
||
@classmethod | ||
def save(cls): | ||
"""Save data source""" | ||
return redirect(url_for("datasource/data_source_controller.home")) | ||
return redirect(url_for("data_source_controller.home")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
"""Site controller, general pages, about us, etc.""" # pylint: disable=invalid-name | ||
|
||
from flask import render_template | ||
from .BaseController import BaseController | ||
|
||
|
||
class SiteController: # pylint: disable=too-few-public-methods | ||
class SiteController(BaseController): # pylint: disable=too-few-public-methods | ||
"""Site Controller""" | ||
|
||
view_subdir = "site" | ||
|
||
@classmethod | ||
def home(cls): | ||
"""Home page""" | ||
return render_template("site/home.html", title="Home") | ||
return cls.render_template("home.html", title="Home") | ||
|
||
@classmethod | ||
def about(cls): | ||
"""About page""" | ||
return render_template("site/about.html", title="About") | ||
return cls.render_template("about.html", title="About") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.