Skip to content

Commit

Permalink
перенос топика между новостями/галереей/статьями
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcom committed Oct 15, 2024
1 parent 1fae0e1 commit 8ccc094
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 1998-2023 Linux.org.ru
* Copyright 1998-2024 Linux.org.ru
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -128,26 +128,35 @@ class TopicModificationController(prepareService: TopicPrepareService, messageDa
}

@RequestMapping(value = Array("/mt.jsp"), method = Array(RequestMethod.GET))
def moveTopicFormForum(@RequestParam msgid: Int): ModelAndView = ModeratorOnly { _ =>
def moveToForumForm(@RequestParam msgid: Int): ModelAndView = ModeratorOnly { _ =>
val topic = messageDao.getById(msgid)
val section = sectionService.getSection(Section.SECTION_FORUM)

new ModelAndView("mtn", Map (
"message" -> topic,
"groups" -> groupDao.getGroups(section),
"groups" -> groupDao.getGroups(section).asScala.map(g => g.id -> g.title).asJava,
"author" -> userService.getUserCached(topic.authorUserId)
).asJava)
}

@RequestMapping(value = Array("/mtn.jsp"), method = Array(RequestMethod.GET))
@throws[Exception]
def moveTopicForm(@RequestParam msgid: Int): ModelAndView = ModeratorOnly { _ =>
def movePremoderatedForm(@RequestParam msgid: Int): ModelAndView = ModeratorOnly { _ =>
val topic = messageDao.getById(msgid)
val section = sectionService.getSection(topic.sectionId)

val currentSection = sectionService.getSection(topic.sectionId)

val sections = if (currentSection.isPremoderated && !currentSection.isPollPostAllowed) {
sectionService.sections.filter(s => s.isPremoderated && !s.isPollPostAllowed)
} else {
Seq(currentSection)
}

val groups = sections.flatMap(g => groupDao.getGroups(g).asScala)

new ModelAndView("mtn", Map(
"message" -> topic,
"groups" -> groupDao.getGroups(section),
"groups" -> groups.map(g => g.id -> s"${sectionService.getSection(g.sectionId).getTitle}: ${g.title}").asJava,
"author" -> userService.getUserCached(topic.authorUserId)
).asJava)
}
Expand Down
47 changes: 28 additions & 19 deletions src/main/webapp/WEB-INF/jsp/mtn.jsp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%@ page contentType="text/html; charset=utf-8"%>
<%--
~ Copyright 1998-2015 Linux.org.ru
~ Copyright 1998-2024 Linux.org.ru
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
Expand All @@ -20,28 +20,37 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<jsp:include page="/WEB-INF/jsp/head.jsp"/>
<title>Перенос</title>
<title>Перенос топика</title>
<jsp:include page="/WEB-INF/jsp/header.jsp"/>
перенос <strong>${message.id}</strong> в группу:
<form method="post" action="/mt.jsp">

<h1>Перенос топика</h1>

<form method="post" action="/mt.jsp" style="margin-top: 1em">
<lor:csrf/>
<input type=hidden name="msgid" value="${message.id}">
<select name="moveto">
<c:forEach var="group" items="${groups}">
<c:if test="${group.id == message.groupId}">
<option value="${group.id}" selected="selected">${group.title}</option>
</c:if>
<c:if test="${group.urlName != \"club\"}">
<c:if test="${group.id != message.groupId}">
<option value="${group.id}">${group.title}</option>
</c:if>
</c:if>
</c:forEach>
</select>
<input type='submit' name='move' value='move'>
<div class="control-group">
<label>
Группа:
<select name="moveto">
<c:forEach var="group" items="${groups}">
<c:if test="${group._1() == message.groupId}">
<option value="${group._1()}" selected="selected">${group._2()}</option>
</c:if>
<c:if test="${group._1() != message.groupId}">
<option value="${group._1()}">${group._2()}</option>
</c:if>
</c:forEach>
</select>
</label>
</div>

<div class="form-actions">
<button type='submit' class="btn btn-primary">Переместить</button>
</div>
</form>

сообщение написано
<lor:user user="${author}"/>, score=${author.score}
<p>
Сообщение написано <lor:user user="${author}"/>, score=${author.score}
</p>

<jsp:include page="/WEB-INF/jsp/footer.jsp"/>

0 comments on commit 8ccc094

Please sign in to comment.