diff --git a/app/controllers/EnrollOrganizationApp.java b/app/controllers/EnrollOrganizationApp.java index 33d5b434d..ea118f99c 100644 --- a/app/controllers/EnrollOrganizationApp.java +++ b/app/controllers/EnrollOrganizationApp.java @@ -36,7 +36,7 @@ public static Result enroll(String organizationName) { return result.getResult(); } - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); if (!User.enrolled(organization)) { User user = UserApp.currentUser(); user.enroll(organization); @@ -47,7 +47,7 @@ public static Result enroll(String organizationName) { } private static ValidationResult validateForEnroll(String organizationName) { - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); if (organization == null) { return new ValidationResult(badRequest(), true); } @@ -67,7 +67,7 @@ public static Result cancelEnroll(String organizationName) { return result.getResult(); } - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); if (User.enrolled(organization)) { User user = UserApp.currentUser(); user.cancelEnroll(organization); @@ -78,7 +78,7 @@ public static Result cancelEnroll(String organizationName) { } private static ValidationResult validateForCancelEnroll(String organizationName) { - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); if (organization == null) { return new ValidationResult(badRequest(), true); } diff --git a/app/controllers/OrganizationApp.java b/app/controllers/OrganizationApp.java index 5c7f1c9de..36a119b52 100644 --- a/app/controllers/OrganizationApp.java +++ b/app/controllers/OrganizationApp.java @@ -129,7 +129,7 @@ public static Result addMember(String organizationName) { } User user = User.findByLoginId(addMemberForm.get().loginId); - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); OrganizationUser.assignRole(user.id, organization.id, RoleType.ORG_MEMBER.roleType()); organization.cleanEnrolledUsers(); NotificationEvent.afterOrganizationMemberRequest(organization, user, RequestState.ACCEPT); @@ -146,7 +146,7 @@ private static Result validateForAddMember(Form addMemberForm, String orga return redirect(routes.OrganizationApp.members(organizationName)); } - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); if (organization == null) { flash(Constants.WARNING, "organization.member.unknownOrganization"); return redirect(routes.OrganizationApp.members(organizationName)); @@ -173,7 +173,7 @@ public static Result deleteMember(String organizationName, Long userId) { return result; } - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); OrganizationUser.delete(organization.id, userId); if (UserApp.currentUser().id.equals(userId)) { @@ -184,7 +184,7 @@ public static Result deleteMember(String organizationName, Long userId) { } private static Result validateForDeleteMember(String organizationName, Long userId) { - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); if (organization == null) { return notFound(ErrorViews.NotFound.render("organization.member.unknownOrganization", organization)); } @@ -217,7 +217,7 @@ public static Result editMember(String organizationName, Long userId) { return result; } - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); OrganizationUser.assignRole(userId, organization.id, roleForm.get().id); return status(Http.Status.NO_CONTENT); @@ -229,7 +229,7 @@ private static Result validateForEditMember(Form roleForm, String organiza return okWithLocation(routes.OrganizationApp.members(organizationName).url()); } - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); if (organization == null) { return notFound(ErrorViews.NotFound.render("organization.member.unknownOrganization", organization)); } @@ -258,13 +258,13 @@ public static Result members(String organizationName) { return result; } - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); return ok(members.render(organization, Role.findOrganizationRoles())); } private static Result validateForSetting(String organizationName) { - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); if (organization == null) { return notFound(ErrorViews.NotFound.render("organization.member.unknownOrganization", organization)); } @@ -283,7 +283,7 @@ public static Result settingForm(String organizationName) { return result; } - Organization organization = Organization.findByOrganizationName(organizationName); + Organization organization = Organization.findByName(organizationName); return ok(setting.render(organization, form(Organization.class).fill(organization))); } diff --git a/app/models/Organization.java b/app/models/Organization.java index b502945a8..2e21684b5 100644 --- a/app/models/Organization.java +++ b/app/models/Organization.java @@ -68,7 +68,7 @@ public void add(OrganizationUser ou) { } public static Organization findByName(String name) { - return find.where().eq("name", name).findUnique(); + return find.where().ieq("name", name).findUnique(); } public static boolean isNameExist(String name) { @@ -93,7 +93,7 @@ public void cleanEnrolledUsers() { } } - public List getVisiableProjects(User user) { + public List getVisibleProjects(User user) { List result = new ArrayList<>(); if(OrganizationUser.isAdmin(this.id, user.id)) { result.addAll(this.projects); @@ -121,10 +121,6 @@ public int compare(Project p1, Project p2) { return result; } - public static Organization findByOrganizationName(String organizationName) { - return find.where().ieq("name", organizationName).findUnique(); - } - /** * Find organizations which contains {@code userLoginId} as member. * diff --git a/app/views/organization/view.scala.html b/app/views/organization/view.scala.html index 354b2f033..b49f1f5fa 100644 --- a/app/views/organization/view.scala.html +++ b/app/views/organization/view.scala.html @@ -46,7 +46,7 @@

@org.descr

    - @for(project <- org.getVisiableProjects(UserApp.currentUser())) { + @for(project <- org.getVisibleProjects(UserApp.currentUser())) {