Log-In and Registration:
We have set some values for login by default. We can also make a new account through registration. The credentials are saved on case class User. The login page looks like this. The log-in view comes from the view “userLogin.scala.html” and the registration page view comes from the view “userRegister.scala.html”.
Similarly, the registration page looks like this.
Access to site:
When we are logged out, we can still see the posts, votes, answers, comments. We can also sort the post by date, vote. But we cannot make any vote, answer, or comment. The below view comes from the View “index.scala.html”.
We can see that even being logged out we have access to the posts but not any functionalities.
Functionalities:
Add Post:
We can add new post by clicking “Add New Post”. There we have three input fields where we can write the title, problem statement and put our code. This view comes from the view “addNewPost.scala.html”.
Add Answers and Add Comment:
Any logged-in user can answer or comment by clicking on the “Add Answer” or “Add Comment” button. It will redirect to a page where they can input their comment or answer. We can see that in the below 3 figures. The “Add Answer” view comes from the View “addNewComment.scala.html” and the “Add Comment” view comes from the View “addComment.scala.html”.
Sorting:
By clicking on the “Sort By Date” and “Sort By Vote” we can sort all the posts according to date or votes. It can be done both by a logged-in user and a logged-out user.
Vote Unvote:
A logged in user can vote a post and unvote a post by clicking on the “Vote” and “Unvote” button which is situated on the left side of all the posts.
Clicking vote will increment vote by 1 and clicking unvote will decrement vote by 1.
Models:
We have 5 models and each of them are described as below:
Global:
We save the session_username_key here. It saves the username for every session.
Post and PostDao:
Mainly the case class Post is in the Post model and object for the Post Model is in the PostDao where mainly all the functionalities are saved e.g., posts, answers, comments, votes, etc.
User and UserDao:
In the User model the case class “User” exists and on the UserDao all the usernames and password are saved.
Controllers:
We have in total 6 controllers and each of them with their functions are described as below:
AuthenticatedUserAction:
From this controller we use the function invokeBlock(). This function works to block all our functionalities if the user is not logged-in.
AuthenticatedUserController:
From this controller we use the function logout() to log out any user and redirect to the login page.
LandingPageController:
This controller is used to redirect to the login landing page. When a user logs in then the first page that pops up, it happens due to this controllers with the function index().
PostController:
This is the most important controller. All the functionalities after loggin in happens through this controller. Description of each function are given on the code. UserController:
Through this controller the user login and registration take place.