Skip to content

Commit

Permalink
Merge pull request #188 from E0191729/master
Browse files Browse the repository at this point in the history
1) Added the PPP for E0191729
  • Loading branch information
xllx1 committed Nov 12, 2018
2 parents e2bcc99 + c767f7c commit 51b49d6
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 39 deletions.
33 changes: 26 additions & 7 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ Data are saved in encrypted Json format, the encryption algorithm is provided by

`RunningId` does not work as the other entities do, it has its own logic to make sure IDs are not repeated.
// end::storage[]

// tag::UserManagement1[]
=== User management

==== Current Implementation
Expand All @@ -324,7 +324,7 @@ The user management is facilitated by various commands. It extends `ForumBook` w

* `LogoutCommand`: logout from the forum book.

* `UpdateCommand`: Update a certain user's password, email and/or phone.
* `UserDeleteCommand`: Self delete a user from the forum book.

Given below is an example usage scenario and how the user management behaves at each step.

Expand All @@ -338,10 +338,10 @@ Step 2. The user executes `login uName/UserName uPass/password` to login to the
Step 3. The user executes `logout` to exit the forum or to switch user, logout command calls 'EventsCenter.getInstance().post(new UserLoginEvent("", false, false))' to close the instance created by the user. Next/ another user is able to login after a successful logout.

ToDo:
Step 4. The user executes `updateUserComment ` to update the uPass.
Step 4. The user executes `UserDeleteComment ` to remove himself/herself from the forum book. User data will be removed from the storage.

----------------------------------------------------------------------------------------------------------------------------------------------------- +

// end::UserManagement1[]
// tag::adminManagement[]
=== Admin management

Expand Down Expand Up @@ -664,6 +664,12 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un

|`* * *` |ForumBook admin |announce |show some important information to users

|`* * *` |User |add myself as a user | register and use the forum book

|`* * *` |User |login and logout |share my comments in the forum book and exit when i want to

|`* * *` |User |delete myself from being a user |

|`* * *` |ForumBook admin |block users |prevent users from creating and updating threads and comments

|`* *` |ForumBook admin |change user password |help the user to reset the password once they forget their password
Expand Down Expand Up @@ -863,7 +869,7 @@ These instructions only provide a starting point for testers to work on; testers
.. Re-launch the app by double-clicking the jar file. +
Expected: The most recent window size and location is retained.


// tag::UserManagement2[]
=== Registering and logging in

. Registering a new user
Expand All @@ -881,7 +887,7 @@ These instructions only provide a starting point for testers to work on; testers
.. Test case: `login uName/john uPass/123`
Expected: Log in with a registered username and correct password, a success message will be shown in the result display panel.


// end::UserManagement2[]
=== Announcing new announcement

. Announcing a new announcement by admin.
Expand Down Expand Up @@ -1064,11 +1070,24 @@ These instructions only provide a starting point for testers to work on; testers
.. Test case: `updatePass uName/abcd uPass/123` +
Expected: Since the given user `abcd` has not been added to the UserStorage, an error message will be shown in the result display panel.

=== Deleting a user
=== Deleting a user(Admin)

. Deleting a given user by admin.
.. Prerequisites: Current user must login as an admin. The given user must be in the UserStorage.
.. Test case: `deleteUser uName/john`
Expected: The user `john` will be deleted from the UserStorage and a success message will be shown in the result display panel.
.. Test case: `deleteUser uName/abcd`
Expected: Since the given user `abcd` does not exist in the UserStorage, an error message will be shown in the result display panel.

// tag::UserManagement3[]
=== Deleting a user(User)

. Self Deleting a user.
.. Prerequisites: User who is interested in removing himself from the forum must login to his account. The given user must be in the UserStorage.
.. Test case: `deleteMe` -user logged in
Expected Success: The current user will be deleted from the UserStorage and a success message will be shown in the result display panel.
.. Test case: `deleteMe` -user not logged in
Expected Fail: Since the given user is not logged in, an error message will be shown in the result display panel.
// end::UserManagement3[].. _{explain how to simulate a missing/corrupted file and the expected behavior}_
// end::others[]

25 changes: 19 additions & 6 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ e.g. typing *`help`* and pressing kbd:[Enter] will open the help window.
9. Update a thread created by you using `updateThread tId/1 tTitle/Is there any midterm?`
10. Delete a thread created by you using `deleteThread tId/1`
11. Check for latest announcement using `checkAnnounce`
12. Logout from ForumBook using `logout`
13. Exits the app using `exit`
12. Delete himself from the ForumBook using 'deleteMe'
13. Logout from ForumBook using `logout`
14. Exits the app using `exit`

* As an admin, you could do anything that an ordinary user could do and the following: +
1. Post new announcement using `announce aTitle/Urgent! aContent/System maintenance from 3pm to 5pm`
Expand Down Expand Up @@ -85,7 +86,7 @@ e.g. typing *`help`* and pressing kbd:[Enter] will open the help window.
=== Viewing help : `help`

Format: `help`

// tag::UserManagement1[]
=== Register a new User : `addUser`

Register a New User to the Forum. User Name is unique and case sensitive. +
Expand All @@ -106,6 +107,7 @@ Format: `login uName/USER NAME uPass/USER PASSWORD`
Examples:

* `login uName/user1 uPass/user1`
// end::UserManagement1[]

// tag::curd[]
=== Listing all the modules : `listModule`
Expand Down Expand Up @@ -281,7 +283,7 @@ Example:

* `updatePass uName/john uPass/098`

=== Delete a user : `deleteUser`
=== Delete a user(Admin) : `deleteUser`

Delete a given user by admin. +
Format: `deleteUser uName/USER_NAME`
Expand All @@ -291,11 +293,21 @@ Example:
* `deleteUser uName/john`
// end::adminManagement[]

// tag::UserManagement2[]
=== Delete a user(User) : `deleteMe`

User deletes himself from the ForumBook. +
Format: `deleteMe`

Example:

* `deleteMe`

=== Logout from the forum : `logout`

Logout from the Forum. +
Format: `logout`

// end::UserManagement2[]
=== Exiting the program : `exit`

Exits the program. +
Expand Down Expand Up @@ -369,6 +381,7 @@ e.g `updateModule mId/3 mCode/CS1221 mTitle/Random CS module`
e.g `deleteModule mCode/CS2113`
* *UpdatePass* : `updatePass uName/USER_NAME uPass/USER_PASSWORD` +
e.g `updatePass uName/john uPass/098`
* *DeleteUser* : `deleteUser uName/USER_NAME` +
* *DeleteUser(Admin)* : `deleteUser uName/USER_NAME` +
e.g `deleteUser uName/john`
* *DeleteUser(User)* : `deleteMe`
* *Logout* : `logout`
35 changes: 16 additions & 19 deletions docs/team/e0191729.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,22 @@ ForumBook is a desktop forum application which allows students to exchange infor

* *Main feature implemented:*: added *various commands to enable admin to manage ForumBook*
** What it does: allows admin to better manage ForumBook by providing the following commands:
<Edit from here to the end>
*** `AnnounceCommand`: admin is able to create new announcement.
*** `CheckAnnouncementCommand`: both user and admin are able to check for latest announcement, which is shown in a pop up window.
*** `BlockUserFromPostingCommand`: admin is able to block a given user.
*** `SetAdminCommand`: admin is able to set a user as admin or revert an admin to user.
*** `CreateModuleCommand`: admin is able to create modules.
*** `DeleteModuleCommand`: admin is able to delete modules.
*** `AdminUpdatePasswordCommand`: admin is able to update a user's password.
*** `DeleteUserCommand`: admin is able to delete a certain user.
** Justification: This admin management feature improves the product significantly as a new user type, admin, is introduced. These admin commands provide a convenient way for admin to better manage the ForumBook.
** Highlights: This admin management feature provides a more efficient way for admin to manage ForumBook, admin could easily block a certain user, help a user to update his/her password, etc. It also made ForumBook more user-friendly as it provides a better way of viewing data by showing the login status of the current user in the label at the top right corner, as well as showing the latest announcement in a pop up window.

*** `AddUser`: add user to the ForumBook database.
*** `Login`: allow user to login to the ForumBook to Read and Share comments.
*** `Logout`: allow user to logout of the ForumBook safely
*** `SelfDeleteUser`: user is able to delete himself from the ForumBook database.
** Justification: This user management feature provides the users the most basic commands required for the user to use the ForumBook. These user commands provide a convenient way for users to better manage the ForumBook.
** Highlights: This user management feature provides the most simplest and efficient way for users to use/manage ForumBook. User could easily add themselves to the ForumBook, login to use the other features, logout of the ForumBook and if there is a need to, delete himself from the ForumBook. It also made ForumBook more user-friendly as it provides a better way of viewing data by showing the login status of the current user in the label at the top right corner, as well as showing the latest announcement in a pop up window.
* *Other contributions*:

** Project management:
*** Managed releases `v1.3` - `v1.4` (2 releases) on GitHub
*** Managed releases `v1.1`(1 releases) on GitHub
** Documentation:
*** Did cosmetic tweaks to existing contents of the User Guide: https://github.com/CS2113-AY1819S1-T13-2/main/pull/4[#4], https://github.com/CS2113-AY1819S1-T13-2/main/pull/77[#77], https://github.com/CS2113-AY1819S1-T13-2/main/pull/98[#98], https://github.com/CS2113-AY1819S1-T13-2/main/pull/114[#114], https://github.com/CS2113-AY1819S1-T13-2/main/pull/120[#120], https://github.com/CS2113-AY1819S1-T13-2/main/pull/122[#122], https://github.com/CS2113-AY1819S1-T13-2/main/pull/124[#124], https://github.com/CS2113-AY1819S1-T13-2/main/pull/149[#149]
*** Did cosmetic tweaks to existing contents of the Developer Guide: https://github.com/CS2113-AY1819S1-T13-2/main/pull/[#6], https://github.com/CS2113-AY1819S1-T13-2/main/pull/62[#62], https://github.com/CS2113-AY1819S1-T13-2/main/pull/73[#73], https://github.com/CS2113-AY1819S1-T13-2/main/pull/77[#77], https://github.com/CS2113-AY1819S1-T13-2/main/pull/102[#102], https://github.com/CS2113-AY1819S1-T13-2/main/pull/109[#109], https://github.com/CS2113-AY1819S1-T13-2/main/pull/119[#119], https://github.com/CS2113-AY1819S1-T13-2/main/pull/120[#120], https://github.com/CS2113-AY1819S1-T13-2/main/pull/124[#124]
*** Did cosmetic tweaks to existing contents of the User Guide: https://github.com/CS2113-AY1819S1-T13-2/main/pull/85[#85], https://github.com/CS2113-AY1819S1-T13-2/main/pull/107[#107], https://github.com/CS2113-AY1819S1-T13-2/main/pull/119[119], https://github.com/CS2113-AY1819S1-T13-2/main/pull/187[#187]
*** Did cosmetic tweaks to existing contents of the Developer Guide: https://github.com/CS2113-AY1819S1-T13-2/main/pull/8[#8], https://github.com/CS2113-AY1819S1-T13-2/main/pull/107[#107], https://github.com/CS2113-AY1819S1-T13-2/main/pull/119[119], https://github.com/CS2113-AY1819S1-T13-2/main/pull/187[#187]
** Community:
*** PRs reviewed (with non-trivial review comments): https://github.com/CS2113-AY1819S1-T13-2/main/pull/48[#48], https://github.com/CS2113-AY1819S1-T13-2/main/pull/50[#50], https://github.com/CS2113-AY1819S1-T13-2/main/pull/81[#81]
*** Reported bugs and suggestions for other teams in the class: https://github.com/nusCS2113-AY1819S1/pe-1/issues/46[#46], https://github.com/nusCS2113-AY1819S1/pe-1/issues/145[#145], https://github.com/nusCS2113-AY1819S1/pe-1/issues/218[#218], https://github.com/nusCS2113-AY1819S1/pe-1/issues/323[#323], https://github.com/nusCS2113-AY1819S1/pe-1/issues/394[#394], https://github.com/nusCS2113-AY1819S1/pe-1/issues/453[#453], https://github.com/nusCS2113-AY1819S1/pe-1/issues/511[#511]
*** PRs reviewed (with non-trivial review comments): https://github.com/CS2113-AY1819S1-T13-2/main/issues/154[#154], https://github.com/CS2113-AY1819S1-T13-2/main/issues/45[#45], https://github.com/CS2113-AY1819S1-T13-2/main/issues/29[#29],
*** Reported bugs and suggestions for other teams in the class: https://github.com/CS2113-AY1819S1-T09-1/main/issues/123[#123], https://github.com/CS2113-AY1819S1-T09-1/main/issues/119[#119], https://github.com/CS2113-AY1819S1-T09-1/main/issues/116[#116], https://github.com/CS2113-AY1819S1-T09-1/main/issues/104[#104]

== Contributions to the User Guide

Expand All @@ -47,12 +41,15 @@ ForumBook is a desktop forum application which allows students to exchange infor
|_Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users._
|===

include::../UserGuide.adoc[tag=adminManagement]
include::../UserGuide.adoc[tag=UserManagement1]
include::../UserGuide.adoc[tag=UserManagement2]

== Contributions to the Developer Guide

|===
|_Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project._
|===

include::../DeveloperGuide.adoc[tag=adminManagement]
include::../DeveloperGuide.adoc[tag=UserManagement1]
include::../DeveloperGuide.adoc[tag=UserManagement2]
include::../DeveloperGuide.adoc[tag=UserManagement3]
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
import com.t13g2.forum.model.forum.User;
import com.t13g2.forum.storage.forum.EntityDoesNotExistException;

//@@author e0191729
/**
*
* Add a person to the ForumBook
*/
public class AddUserCommand extends Command {
/**
Expand All @@ -29,7 +30,6 @@ public class AddUserCommand extends Command {


public static final String MESSAGE_SUCCESS = "WELCOME : %1$s. You had been successfully been registered.";
//public static final String MESSAGE_FAIL = "No user named %1$s found or password is wrong";
public static final String MESSAGE_DUPLICATE_PERSON = "This user name already exists, Please use another name.";
private final User userToAdd;

Expand Down Expand Up @@ -62,8 +62,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
unitOfWork.getUserRepository().addUser(userToAdd);
unitOfWork.commit();
} else {
throw new CommandException(String.format(MESSAGE_DUPLICATE_PERSON));
//return new CommandResult(String.format(MESSAGE_DUPLICATE_PERSON, userToAdd.getUsername()));
throw new CommandException(MESSAGE_DUPLICATE_PERSON);
}

return new CommandResult(String.format(MESSAGE_SUCCESS, userToAdd.getUsername()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
import com.t13g2.forum.model.forum.User;
import com.t13g2.forum.storage.forum.EntityDoesNotExistException;

//@@author e0191729
/**
* Deletes a specific user by admin
* Self deletes a user from the ForumBook
*/
public class DeleteUserCommand extends Command {
public static final String COMMAND_WORD = "deleteUser";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
import com.t13g2.forum.model.forum.User;
import com.t13g2.forum.storage.forum.EntityDoesNotExistException;

//@@author e0191729
/**
*
* Login to the ForumBook
*/
public class LoginCommand extends Command {
public static final String COMMAND_WORD = "login";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import com.t13g2.forum.logic.commands.exceptions.CommandException;
import com.t13g2.forum.model.Context;
import com.t13g2.forum.model.Model;

//@@author e0191729
/**
*
*LogOut of ForumBook
*/
public class LogoutCommand extends Command {
public static final String COMMAND_WORD = "logout";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.t13g2.forum.logic.commands;

import static java.util.Objects.requireNonNull;

import com.t13g2.forum.commons.core.EventsCenter;
import com.t13g2.forum.commons.events.model.UserLoginEvent;
import com.t13g2.forum.logic.CommandHistory;
import com.t13g2.forum.logic.commands.exceptions.CommandException;
import com.t13g2.forum.model.Context;
import com.t13g2.forum.model.Model;
import com.t13g2.forum.model.UnitOfWork;
import com.t13g2.forum.model.forum.User;

/**
*
*/
public class UserDeleteCommand extends Command {
public static final String COMMAND_WORD = "deleteMe";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Self delete user from the forum book. ";

public static final String MESSAGE_SUCCESS = "It was nice knowing you! Good bye %1$s :(";
public static final String MESSAGE_FAIL = "No user logged in for Self Delete";


private String userName;
@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
requireNonNull(model);
if (Context.getInstance().getCurrentUser() != null) {
try (UnitOfWork unitOfWork = new UnitOfWork()) {
User userToDelete = Context.getInstance().getCurrentUser();
userName = userToDelete.getUsername();
unitOfWork.getUserRepository().deleteUser(userToDelete);
unitOfWork.commit();
Context.getInstance().setCurrentUser(null);
} catch (Exception e) {
e.printStackTrace();
}
EventsCenter.getInstance().post(new UserLoginEvent("", false, false));
return new CommandResult(String.format(MESSAGE_SUCCESS, userName));
} else {
return new CommandResult(String.format(MESSAGE_FAIL, userName));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.t13g2.forum.logic.commands.UpdateCommentCommand;
import com.t13g2.forum.logic.commands.UpdateModuleCommand;
import com.t13g2.forum.logic.commands.UpdateThreadCommand;
import com.t13g2.forum.logic.commands.UserDeleteCommand;
import com.t13g2.forum.logic.parser.exceptions.ParseException;

/**
Expand Down Expand Up @@ -161,6 +162,9 @@ public Command parseCommand(String userInput) throws ParseException {
case LogoutCommand.COMMAND_WORD:
return new LogoutCommand();

case UserDeleteCommand.COMMAND_WORD:
return new UserDeleteCommand();

default:
throw new ParseException(MESSAGE_UNKNOWN_COMMAND);
}
Expand Down
Loading

0 comments on commit 51b49d6

Please sign in to comment.