예제 #1
0
    def __init__(self):
        """Class initialization."""

        self.view = CategoryView()
        self.model = self.view.model

        self.category_id = None
    def run(self):
        """Run the app."""
        while self.running:
            menu_controller = MainPage()
            user_choice = menu_controller.get_input()

            if user_choice == 1:
                category_controller = CategoryPage()
                CategoryView.display_choices(category_controller.categories)
                category = category_controller.get_input()

                product_controller = ProductPage(category)
                ProductView.display_choices(product_controller.products)
                product = product_controller.get_input()

                substitute_controller = SubstitutePage(
                    category, product["nutriscore_id"])
                if SubstituteView.display_choices(
                        substitute_controller.substitute):
                    substitute_controller.get_input(product)

            elif user_choice == 2:
                substitute_view = SubstituteView()
                substitute_view.display_saved_substitutes()

            elif user_choice == 3:
                self.running = False
예제 #3
0
def init_views(flask_app, config):
    """ Initialize views. """

    from app.views.api_index import ApiIndexView
    ApiIndexView.register(flask_app, route_base='/api/')

    from app.views.authenticate import AuthenticationView
    AuthenticationView.register(flask_app, route_base='/api/authentication/')

    from app.views.configuration import ConfigurationView
    ConfigurationView.register(flask_app, route_base='/api/configuration/')

    from app.views.proxies import ProxiesView
    ProxiesView.register(flask_app, route_base='/api/proxies/')

    from app.views.file import FileView
    FileView.register(flask_app, route_base='/api/files/')

    from app.views.notification import NotificationView
    NotificationView.register(flask_app, route_base='/api/notification/')
    flask_app.atexit(NotificationView.quit_notifications)

    from app.views.site import SiteView
    SiteView.register(flask_app, route_base='/api/sites/')

    from app.views.tasks import TasksView
    TasksView.register(flask_app, route_base='/api/tasks/')

    from app.views.user import UserView
    UserView.register(flask_app, route_base='/api/users/')

    from app.views.username import UsernameView
    UsernameView.register(flask_app, route_base='/api/username/')

    from app.views.category import CategoryView
    CategoryView.register(flask_app, route_base='/api/categories/')

    from app.views.archive import ArchiveView
    ArchiveView.register(flask_app, route_base='/api/archives/')

    from app.views.result import ResultView
    ResultView.register(flask_app, route_base='/api/results/')

    from app.views.checkout import CheckoutView
    CheckoutView.register(flask_app, route_base='/api/checkout/')

    # Make sure to import the Angular view last so that it will match
    # all remaining routes.
    import app.views.angular
예제 #4
0
 def get_input(self) -> str:
     """Return user's category choice."""
     user_choice = None
     while user_choice not in range(len(self.categories)):
         try:
             user_choice = CategoryView.display_input()
             category_choice = self.categories[user_choice][user_choice]
         except ValueError:
             pass
         except IndexError:
             pass
         else:
             return category_choice
예제 #5
0
class CategoryController():

    def __init__(self):
        """Class initialization."""

        self.view = CategoryView()
        self.model = self.view.model

        self.category_id = None

    def display(self):
        """Method displaying page."""

        self.view.display()

    def get_command(self):
        """Method getting user input."""

        choice = input("> ")

        if choice.startswith("p-"):
            choice = int(choice.replace("p-", ""))
            if choice <= self.model.max_pages and choice > 0:
                self.model.page = choice
        elif choice == "n":
            if self.model.page < self.model.max_pages:
                self.model.page += 1
        elif choice == "b":
            if self.model.page > 1:
                self.model.page -= 1
        elif choice == "q":
            return "quit"
        elif choice.isdigit():
            self.category_id = choice
            return "goto-product"

        self.model.limit = self.model.page_size * (self.model.page - 1)
예제 #6
0
파일: urls.py 프로젝트: SiDChik/verkhovskiy
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.contrib import admin
from app import settings
from app.settings import DEBUG
from app.views.category import CategoryView
from app.views.main import MainView
from app.views.page import PageView

urlpatterns = patterns('',
    # Examples:
    url(r'^$', MainView.as_view(), name='home'),
    url(r'^albums/(?P<alias>[\w]+)$', CategoryView.as_view(), name='category'),
    url(r'^(?P<page>[0-9a-z]+)$', PageView.as_view(), name='page'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
    (r'^ckeditor/', include('ckeditor.urls')),
)

if DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)