From b28b1bb745e615ec29b9421c4057351fad8eb7bd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 10 Feb 2014 17:30:42 -0500 Subject: update the controllers --- docs/DesignDocument.dot | 140 +++++++++++++++++++++++++++--------------------- docs/DesignDocument.md | 72 +++++++++++++++++-------- 2 files changed, 129 insertions(+), 83 deletions(-) diff --git a/docs/DesignDocument.dot b/docs/DesignDocument.dot index 3be050b..000256d 100644 --- a/docs/DesignDocument.dot +++ b/docs/DesignDocument.dot @@ -1,82 +1,102 @@ digraph systemModel { rankdir="LR"; - node[shape="record"]; + splines="line"; - #subgraph clusterModels { - # label="Models" - User[label=" User | role | password hash"]; - #} + subgraph _clusterModels { + label="Models" + node[shape="record"]; + + BaseModel[label="
ActiveRecord::Base (abstract)"] + User[label="
User | role | password hash"]; + } - ApplicationController[label="ApplicationController (abstract base class)"]; - #subgraph clusterControllers { - # label="Controllers"; - MainController[label=" MainController | show_homepage() | edit_settings() | update_settings()"]; - TournamentController[label=" TournamentController | listTournaments | newTournament | showTournament | editTournament | endTournament"]; - MessageController; - LoginController[label=" LoginController | showForm | login | logout"]; - SearchController; - UserController; - MatchController; - #} - #subgraph clusterViews { - # label="views/"; - subgraph clusterCommonViews { + subgraph _clusterControllers { + label="Controllers"; + node[shape="record"]; + + ApplicationController[label="
ApplicationController (abstract)"]; + + MainController[label="
MainController | show_homepage() | edit_settings() | update_settings()"]; + TournamentsController[label="
TournamentsController | index() | new() | create() | show() | edit() | update() | end()"]; + MessagesController[label="
MessagesController"]; + LoginController[label="
LoginController | login() | logout()"]; + SearchController[label="
SearchController"]; + UsersController[label="
UsersController"]; + MatchesController[label="
MatchesController"]; + } + + subgraph _clusterViews { + label="views/"; + node[shape="rectangle"] + + layouts_application[label="layouts/application.html (abstract)"] + + subgraph clusterViewsCommon { label="views/common/"; common_permission_denied; common_invalid; } - subgraph clusterMainViews { + + subgraph clusterViewsMain { label="views/main/"; main_homepage; main_edit; } - subgraph clusterLoginViews { - label="views/login/"; - login_form - } - subgraph clusterTournamentViews { + subgraph clusterViewsTournament { label="views/tournament/"; - tournament_index; - tournament_new; - tournament_show; - tournament_edit; + tournaments_index; + tournaments_new; + tournaments_show; + tournaments_edit; } - subgraph clusterMessageViews { - label="views/message/"; - message_private; - message_new_alert; + subgraph clusterViewsMessages { + label="views/messages/"; + messages_private; + messages_new_alert; } - #} + } - MainController -> ApplicationController[arrowhead="onormal"]; - MainController:index -> main_homepage; - MainController:edit -> main_edit; - MainController:edit -> common_permission_denied; - MainController:update -> main_edit; - MainController:update -> common_permission_denied; + subgraph inheritance { + edge[arrowhead="onormal"]; + MainController:main -> ApplicationController; + ApplicationController -> MainController:main[style=invis]; + TournamentsController:main -> ApplicationController; + ApplicationController -> TournamentsController:main[style=invis]; + MessagesController:main -> ApplicationController; + ApplicationController -> MessagesController:main[style=invis]; + LoginController:main -> ApplicationController; + ApplicationController -> LoginController:main[style=invis]; + SearchController:main -> ApplicationController; + ApplicationController -> SearchController:main[style=invis]; + UsersController:main -> ApplicationController; + ApplicationController -> UsersController:main[style=invis]; + MatchesController:main -> ApplicationController; + ApplicationController -> MatchesController:main[style=invis]; + } - TournamentController -> ApplicationController[arrowhead="onormal"]; - TournamentController:index -> tournament_index; - TournamentController:new -> tournament_new; - TournamentController:show -> tournament_show; - TournamentController:edit -> tournament_edit; - TournamentController:edit -> common_permission_denied; - TournamentController:delete -> common_permission_denied; + subgraph controller2view { + layouts_application -> LoginController:login; + layouts_application -> LoginController:logout; - MessageController -> ApplicationController[arrowhead="onormal"]; - MessageController -> message_private; - MessageController -> message_new_alert; + MainController:index -> main_homepage; + MainController:edit -> main_edit -> MainController:update; + MainController:edit -> common_permission_denied; + MainController:update -> main_edit; + MainController:update -> common_permission_denied; + TournamentsController:index -> tournaments_index; + TournamentsController:new -> tournaments_new -> TournamentsController:create; + TournamentsController:create -> tournaments_edit -> TournamentsController:end; + TournamentsController:show -> tournaments_show; + TournamentsController:edit -> tournaments_edit -> TournamentsController:update; + TournamentsController:update -> tournaments_edit + TournamentsController:edit -> common_permission_denied; + TournamentsController:end -> common_permission_denied; - LoginController -> ApplicationController[arrowhead="onormal"]; - LoginController:index -> login_form; - LoginController:login -> common_permission_denied; - LoginController:logout -> common_invalid; - - SearchController -> ApplicationController[arrowhead="onormal"]; - - UserController -> ApplicationController[arrowhead="onormal"]; - - MatchController -> ApplicationController[arrowhead="onormal"]; + MessagesController -> messages_private; + MessagesController -> messages_new_alert; + LoginController:login -> common_permission_denied; + LoginController:logout -> common_invalid; + } } diff --git a/docs/DesignDocument.md b/docs/DesignDocument.md index 1adc76c..1c256b0 100644 --- a/docs/DesignDocument.md +++ b/docs/DesignDocument.md @@ -119,13 +119,25 @@ User ### VIEWS +Asynchronous JavaScript may be used to load one view inside of +another. From the core architecture, this does not matter, as the +same HTTP requests are made, though the user interaction is a little +cleaner. + layouts/application.html (abstract) - : An abstract HTML file, all entries below are webpages (we - represent them as sub-classes of the abstract “Webpage” class. All - webpages will send HTTP requests to the server. Most of the visual - effects and update the display with JavaScript methods. Each page - will have a login dialogue which will POST to the login controller - or the logged in user’s page. + : An abstract HTML file, that contains the basic page layout that + all other views inherit. If a user is not logged in, it contains + a login form, and a registration button. The form causes a POST + to `LoginController#login()`, and the button causes a GET to + `UserController#new()`. If a user is logged in, it displays a + logout button that causes a POST to `LoginController#logout()`. + +common/permission_denied.html + : A generic page for when a user attempts to do something for which + they don't have authorization. +common/invalid.html + : A generic page for handling invalid requests (such as logging out + when not logged in). main/homepage.html : This page has 3 basic options. Visually simple – two large buttons @@ -134,15 +146,13 @@ main/homepage.html will cause a POST to the login controller) and “Go to Tournament” in which you enter a tournament title. This interacts with the Homepage Controller. - main/edit.html : This page is a form for editing the server-wide configuration, such as the language or the graphical theme. -login/form.html - : Page with form entries for username, password. If user clicks “new - user” more forms entries will appear. One for repeating the - password, and one for email. This POST to the Login controller. +users/new.html + : One for repeating the password, and one for email. This POST to + the Login controller. tournaments/new.html : A form that interacts with users who are either hosts or becoming @@ -198,7 +208,7 @@ MainController `common/permission_denied` view. This involves interacting with the `User` model to determine whether the user is authorized to see this. - - `update_settings()` Responds to POST requests by updating the + - `update_settings()` Responds to POST requests by updating the server configuration with the POSTed settings. It then either renders the `common/permission_denied` view, or the `main/edit` view with the updated settings. This involves interacting with @@ -206,17 +216,33 @@ MainController do this. LoginController - : This controller This has doLogin() and doLogout(). Both have access to the HTTP - request. It will interact with the Users model to validate - passwords and usernames. - -TournamentController - : This controller will have methods: newTournament(), - getTournament(), editTournament(), and endTournament(). All of - these methods will interact with the Tournament model, and all of - its fields including users matches and TournamentSettings. And all - will interact with their tournament view, for example, - newTournament() will render newTournament. + : This controller handles session management. It contains two + methods: + + - `login()` Responds to POST requests by seting a session token + identifying the user. If the credentials are correct, it sends + a redirect that directs the browser to the page it would + otherwise be on. If the credentials are not correct, it renders + the `common/permission_denied` view. This queries the `User` + model to validate the username and password. + - `logout()` Responds to POST requests by clearing the session + token, logging the user out, then redirects to the home page + (`MainController#show_homepage()`). If the was not logged in, + it renders the `common/invalid` view. + +TournamentsController + : This controller will have methods: + + - `new()` Renders the `tournaments/new` view, assuming the user + has permission. Otherwise, renders `common/permission_denied`. + - `create` + - `show()` + - `edit()` + - `update()` + - `end()` + + All of these methods will interact with the Tournament model, and all of + its fields including users matches and TournamentSettings. Server : Rails’ Server class handles all HTTP events. Our Server class is -- cgit v1.2.3