mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-01-30 14:30:08 +08:00
admin project approval works
This commit is contained in:
parent
6e47fc315a
commit
6364126da5
@ -325,8 +325,13 @@ public class ProjectsController extends HangarController {
|
||||
|
||||
@Secured("ROLE_USER")
|
||||
@RequestMapping("/{author}/{slug}/manage/sendforapproval")
|
||||
public Object sendForApproval(@PathVariable Object author, @PathVariable Object slug) {
|
||||
return null; // TODO implement sendForApproval request controller
|
||||
public ModelAndView sendForApproval(@PathVariable String author, @PathVariable String slug, HttpServletRequest request) {
|
||||
ProjectData projectData = projectService.getProjectData(author, slug);
|
||||
if (projectData.getVisibility() == Visibility.NEEDSCHANGES) {
|
||||
projectService.changeVisibility(projectData.getProject(), Visibility.NEEDSAPPROVAL, "");
|
||||
userActionLogService.project(request, LoggedActionType.PROJECT_VISIBILITY_CHANGE.with(ProjectContext.of(projectData.getProject().getId())), Visibility.NEEDSAPPROVAL.getName(), Visibility.NEEDSCHANGES.getName());
|
||||
}
|
||||
return new ModelAndView("redirect:" + routeHelper.getRouteUrl("projects.show", author, slug));
|
||||
}
|
||||
|
||||
@Secured("ROLE_USER")
|
||||
|
@ -4,6 +4,7 @@ import me.minidigger.hangar.db.model.ProjectsTable;
|
||||
import me.minidigger.hangar.db.model.UserProjectRolesTable;
|
||||
import me.minidigger.hangar.db.model.UsersTable;
|
||||
import me.minidigger.hangar.model.Permission;
|
||||
import me.minidigger.hangar.model.generated.ProjectNamespace;
|
||||
import me.minidigger.hangar.model.generated.ProjectStatsAll;
|
||||
import me.minidigger.hangar.model.viewhelpers.ProjectApprovalData;
|
||||
import me.minidigger.hangar.model.viewhelpers.ProjectMember;
|
||||
@ -110,11 +111,11 @@ public interface ProjectDao {
|
||||
|
||||
|
||||
@RegisterBeanMapper(ProjectApprovalData.class)
|
||||
@SqlQuery("SELECT sq.owner_name," +
|
||||
" sq.slug," +
|
||||
" sq.visibility," +
|
||||
" sq.last_comment," +
|
||||
" u.name AS change_requester" +
|
||||
@SqlQuery("SELECT sq.owner_name pn_owner," +
|
||||
" sq.slug pn_slug," +
|
||||
" sq.visibility visibility," +
|
||||
" sq.last_comment \"comment\"," +
|
||||
" u.name change_requester" +
|
||||
" FROM (SELECT p.owner_name," +
|
||||
" p.slug," +
|
||||
" p.visibility," +
|
||||
@ -124,19 +125,19 @@ public interface ProjectDao {
|
||||
" lag(vc.created_by) OVER last_vc AS last_changer" +
|
||||
" FROM projects p" +
|
||||
" JOIN project_visibility_changes vc ON p.id = vc.project_id" +
|
||||
" WHERE p.visibility = 4 WINDOW last_vc AS (PARTITION BY p.id ORDER BY vc.created_at)) sq" +
|
||||
" WHERE p.visibility = 3 WINDOW last_vc AS (PARTITION BY p.id ORDER BY vc.created_at)) sq" +
|
||||
" JOIN users u ON sq.last_changer = u.id" +
|
||||
" WHERE sq.resolved_at IS NULL" +
|
||||
" AND sq.last_visibility = 3" +
|
||||
" AND sq.last_visibility = 2" +
|
||||
" ORDER BY sq.owner_name || sq.slug")
|
||||
List<ProjectApprovalData> getVisibilityNeedsApproval();
|
||||
|
||||
@RegisterBeanMapper(ProjectApprovalData.class)
|
||||
@SqlQuery("SELECT p.owner_name, p.slug, p.visibility, vc.comment, u.name AS change_requester" +
|
||||
@RegisterBeanMapper(value = ProjectApprovalData.class)
|
||||
@SqlQuery("SELECT p.owner_name pn_owner, p.slug pn_slug, p.visibility visibility, vc.comment \"comment\", u.name change_requester" +
|
||||
" FROM projects p" +
|
||||
" JOIN project_visibility_changes vc ON p.id = vc.project_id" +
|
||||
" JOIN users u ON vc.created_by = u.id" +
|
||||
" WHERE vc.resolved_at IS NULL" +
|
||||
" AND p.visibility = 3")
|
||||
" AND p.visibility = 2")
|
||||
List<ProjectApprovalData> getVisibilityWaitingProject();
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package me.minidigger.hangar.model.viewhelpers;
|
||||
|
||||
import me.minidigger.hangar.model.Visibility;
|
||||
import me.minidigger.hangar.model.generated.ProjectNamespace;
|
||||
import org.jdbi.v3.core.enums.EnumByOrdinal;
|
||||
import org.jdbi.v3.core.mapper.Nested;
|
||||
|
||||
public class ProjectApprovalData {
|
||||
|
||||
@ -17,19 +19,41 @@ public class ProjectApprovalData {
|
||||
this.changeRequester = changeRequester;
|
||||
}
|
||||
|
||||
public ProjectApprovalData() { }
|
||||
|
||||
@Nested("pn")
|
||||
public ProjectNamespace getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
@Nested("pn")
|
||||
public void setNamespace(ProjectNamespace namespace) {
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
@EnumByOrdinal
|
||||
public Visibility getVisibility() {
|
||||
return visibility;
|
||||
}
|
||||
|
||||
@EnumByOrdinal
|
||||
public void setVisibility(Visibility visibility) {
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getChangeRequester() {
|
||||
return changeRequester;
|
||||
}
|
||||
|
||||
public void setChangeRequester(String changeRequester) {
|
||||
this.changeRequester = changeRequester;
|
||||
}
|
||||
}
|
||||
|
@ -421,5 +421,5 @@ visibility.notice.public = None
|
||||
visibility.notice.new = This project is new, and will not be shown to others until a version has been uploaded. If a version is not uploaded over a longer time the project will be deleted.
|
||||
visibility.notice.author.new = Click ''Publish'' to publish. This project will automatically be moved from the new stage in 24 hours.
|
||||
visibility.notice.needsChanges = This project requires changes:
|
||||
visibility.notice.needsApproval = You have send the project for review
|
||||
visibility.notice.needsApproval = You have sent the project for review
|
||||
visibility.notice.softDelete = Project deleted by {0}
|
||||
|
@ -4,6 +4,7 @@
|
||||
<#import "*/projects/helper/btnHide.ftlh" as btnHide />
|
||||
|
||||
<#macro renderApprovalList projectSeq>
|
||||
<#-- @ftlvariable name="projectSeq" type="java.util.List<me.minidigger.hangar.model.viewhelpers.ProjectApprovalData>" -->
|
||||
<ul class="list-group list-flags-admin">
|
||||
<#if !projectSeq?has_content>
|
||||
<li class="list-group-item">
|
||||
|
Loading…
Reference in New Issue
Block a user