Resolve "Ping конференции в списке конференций" #196
@ -16,4 +16,7 @@ public interface ConferenceRepository extends JpaRepository<Conference, Integer>
|
|||||||
|
|
||||||
@Query("SELECT c FROM Conference c WHERE c.beginDate > :date")
|
@Query("SELECT c FROM Conference c WHERE c.beginDate > :date")
|
||||||
List<Conference> findAllActive(@Param("date") Date date);
|
List<Conference> findAllActive(@Param("date") Date date);
|
||||||
|
|
||||||
|
@Query("SELECT case when count(c) > 0 then true else false end FROM Conference c JOIN c.papers p WHERE p.id = :paperId")
|
||||||
|
boolean isPaperAttached(@Param("paperId") Integer paperId);
|
||||||
}
|
}
|
||||||
|
@ -184,4 +184,8 @@ public class ConferenceService {
|
|||||||
public List<Conference> findAllActive() {
|
public List<Conference> findAllActive() {
|
||||||
return conferenceRepository.findAllActive(new Date());
|
return conferenceRepository.findAllActive(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAttachedToConference(Integer paperId) {
|
||||||
|
return conferenceRepository.isPaperAttached(paperId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,11 @@ public class AdviceController {
|
|||||||
return userService.getCurrentUser().getUserAbbreviate();
|
return userService.getCurrentUser().getUserAbbreviate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ModelAttribute("flashMessage")
|
||||||
|
public String getFlashMessage() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private Response<Void> handleException(ErrorConstants error) {
|
private Response<Void> handleException(ErrorConstants error) {
|
||||||
log.warn(error.toString());
|
log.warn(error.toString());
|
||||||
return new Response<>(error);
|
return new Response<>(error);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package ru.ulstu.paper.controller;
|
package ru.ulstu.paper.controller;
|
||||||
|
|
||||||
import org.springframework.dao.DataIntegrityViolationException;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@ -9,14 +8,14 @@ import org.springframework.ui.ModelMap;
|
|||||||
import org.springframework.validation.Errors;
|
import org.springframework.validation.Errors;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import ru.ulstu.conference.service.ConferenceService;
|
||||||
import ru.ulstu.deadline.model.Deadline;
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.paper.model.Paper;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.paper.model.PaperDto;
|
||||||
import ru.ulstu.paper.model.PaperFilterDto;
|
import ru.ulstu.paper.model.PaperListDto;
|
||||||
import ru.ulstu.paper.service.LatexService;
|
import ru.ulstu.paper.service.LatexService;
|
||||||
import ru.ulstu.paper.service.PaperService;
|
import ru.ulstu.paper.service.PaperService;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
@ -39,23 +38,34 @@ import static org.springframework.util.StringUtils.isEmpty;
|
|||||||
@ApiIgnore
|
@ApiIgnore
|
||||||
public class PaperController {
|
public class PaperController {
|
||||||
private final PaperService paperService;
|
private final PaperService paperService;
|
||||||
|
private final ConferenceService conferenceService;
|
||||||
private final LatexService latexService;
|
private final LatexService latexService;
|
||||||
|
|
||||||
public PaperController(PaperService paperService, LatexService latexService) {
|
public PaperController(PaperService paperService,
|
||||||
|
ConferenceService conferenceService,
|
||||||
|
LatexService latexService) {
|
||||||
this.paperService = paperService;
|
this.paperService = paperService;
|
||||||
|
this.conferenceService = conferenceService;
|
||||||
this.latexService = latexService;
|
this.latexService = latexService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/papers")
|
@GetMapping("/papers")
|
||||||
public void getPapers(ModelMap modelMap) {
|
public void getPapers(ModelMap modelMap) {
|
||||||
modelMap.put("filteredPapers", new PaperFilterDto(paperService.findAllDto(), null, null));
|
modelMap.put("filteredPapers", new PaperListDto(paperService.findAllDto(), null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/papers")
|
@PostMapping("/papers")
|
||||||
public void filterPapers(@Valid PaperFilterDto paperFilterDto, ModelMap modelMap) {
|
public void listPapers(@Valid PaperListDto paperListDto, ModelMap modelMap) {
|
||||||
modelMap.put("filteredPapers", new PaperFilterDto(paperService.filter(paperFilterDto),
|
if (paperListDto.getPaperDeleteId() != null) {
|
||||||
paperFilterDto.getFilterAuthorId(),
|
if (conferenceService.isAttachedToConference(paperListDto.getPaperDeleteId())) {
|
||||||
paperFilterDto.getYear()));
|
modelMap.put("flashMessage", "Статью нельзя удалить, она прикреплена к конференции");
|
||||||
|
} else {
|
||||||
|
paperService.delete(paperListDto.getPaperDeleteId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modelMap.put("filteredPapers", new PaperListDto(paperService.filter(paperListDto),
|
||||||
|
paperListDto.getFilterAuthorId(),
|
||||||
|
paperListDto.getYear()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/dashboard")
|
@GetMapping("/dashboard")
|
||||||
@ -95,19 +105,6 @@ public class PaperController {
|
|||||||
return "/papers/paper";
|
return "/papers/paper";
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/delete/{paper-id}")
|
|
||||||
public String delete(@Valid PaperFilterDto paperFilterDto,
|
|
||||||
@PathVariable("paper-id") Integer paperId,
|
|
||||||
Errors errors) throws IOException {
|
|
||||||
try {
|
|
||||||
paperService.delete(paperId);
|
|
||||||
} catch (DataIntegrityViolationException e) {
|
|
||||||
errors.reject("relationExist", "Статья прикреплена к конференции");
|
|
||||||
return "/papers/papers";
|
|
||||||
}
|
|
||||||
return "redirect:/papers/papers";
|
|
||||||
}
|
|
||||||
|
|
||||||
@ModelAttribute("allStatuses")
|
@ModelAttribute("allStatuses")
|
||||||
public List<Paper.PaperStatus> getPaperStatuses() {
|
public List<Paper.PaperStatus> getPaperStatuses() {
|
||||||
return paperService.getPaperStatuses();
|
return paperService.getPaperStatuses();
|
||||||
|
@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import ru.ulstu.configuration.Constants;
|
import ru.ulstu.configuration.Constants;
|
||||||
import ru.ulstu.core.model.response.Response;
|
import ru.ulstu.core.model.response.Response;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.paper.model.PaperDto;
|
||||||
import ru.ulstu.paper.model.PaperFilterDto;
|
import ru.ulstu.paper.model.PaperListDto;
|
||||||
import ru.ulstu.paper.service.PaperService;
|
import ru.ulstu.paper.service.PaperService;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@ -58,8 +58,8 @@ public class PaperRestController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/filter")
|
@PostMapping("/filter")
|
||||||
public Response<List<PaperDto>> filter(@RequestBody @Valid PaperFilterDto paperFilterDto) throws IOException {
|
public Response<List<PaperDto>> filter(@RequestBody @Valid PaperListDto paperListDto) throws IOException {
|
||||||
return new Response<>(paperService.filter(paperFilterDto));
|
return new Response<>(paperService.filter(paperListDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("formatted-list")
|
@GetMapping("formatted-list")
|
||||||
|
@ -2,15 +2,16 @@ package ru.ulstu.paper.model;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PaperFilterDto {
|
public class PaperListDto {
|
||||||
private List<PaperDto> papers;
|
private List<PaperDto> papers;
|
||||||
private Integer filterAuthorId;
|
private Integer filterAuthorId;
|
||||||
|
private Integer paperDeleteId;
|
||||||
private Integer year;
|
private Integer year;
|
||||||
|
|
||||||
public PaperFilterDto() {
|
public PaperListDto() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PaperFilterDto(List<PaperDto> paperDtos, Integer filterAuthorId, Integer year) {
|
public PaperListDto(List<PaperDto> paperDtos, Integer filterAuthorId, Integer year) {
|
||||||
this.papers = paperDtos;
|
this.papers = paperDtos;
|
||||||
this.filterAuthorId = filterAuthorId;
|
this.filterAuthorId = filterAuthorId;
|
||||||
this.year = year;
|
this.year = year;
|
||||||
@ -39,4 +40,12 @@ public class PaperFilterDto {
|
|||||||
public void setYear(Integer year) {
|
public void setYear(Integer year) {
|
||||||
this.year = year;
|
this.year = year;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getPaperDeleteId() {
|
||||||
|
return paperDeleteId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaperDeleteId(Integer paperDeleteId) {
|
||||||
|
this.paperDeleteId = paperDeleteId;
|
||||||
|
}
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ import ru.ulstu.file.model.FileDataDto;
|
|||||||
import ru.ulstu.file.service.FileService;
|
import ru.ulstu.file.service.FileService;
|
||||||
import ru.ulstu.paper.model.Paper;
|
import ru.ulstu.paper.model.Paper;
|
||||||
import ru.ulstu.paper.model.PaperDto;
|
import ru.ulstu.paper.model.PaperDto;
|
||||||
import ru.ulstu.paper.model.PaperFilterDto;
|
import ru.ulstu.paper.model.PaperListDto;
|
||||||
import ru.ulstu.paper.repository.PaperRepository;
|
import ru.ulstu.paper.repository.PaperRepository;
|
||||||
import ru.ulstu.timeline.service.EventService;
|
import ru.ulstu.timeline.service.EventService;
|
||||||
import ru.ulstu.user.model.User;
|
import ru.ulstu.user.model.User;
|
||||||
@ -181,7 +181,7 @@ public class PaperService {
|
|||||||
return paper;
|
return paper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PaperDto> filter(PaperFilterDto filterDto) {
|
public List<PaperDto> filter(PaperListDto filterDto) {
|
||||||
return convert(sortPapers(paperRepository.filter(
|
return convert(sortPapers(paperRepository.filter(
|
||||||
filterDto.getFilterAuthorId() == null ? null : userService.findById(filterDto.getFilterAuthorId()),
|
filterDto.getFilterAuthorId() == null ? null : userService.findById(filterDto.getFilterAuthorId()),
|
||||||
filterDto.getYear())), PaperDto::new);
|
filterDto.getYear())), PaperDto::new);
|
||||||
|
@ -13,7 +13,8 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('a[data-confirm]').click(function(ev) {
|
$('a[data-confirm]').click(function(ev) {
|
||||||
var href = $(this).attr('href');
|
var id = $(this).parent().parent().find('.id-class').val();
|
||||||
|
|
||||||
if (!$('#dataConfirmModal').length) {
|
if (!$('#dataConfirmModal').length) {
|
||||||
$('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' +
|
$('#modalDelete').append('<div class="modal fade" id="dataConfirmModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"\n' +
|
||||||
' >\n' +
|
' >\n' +
|
||||||
@ -34,7 +35,10 @@ $(document).ready(function () {
|
|||||||
' </div>');
|
' </div>');
|
||||||
}
|
}
|
||||||
$('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm'));
|
$('#dataConfirmModal').find('#myModalLabel').text($(this).attr('data-confirm'));
|
||||||
$('#dataConfirmOK').attr('href', href);
|
$('#dataConfirmOK').click(function () {
|
||||||
|
$("#paperDeleteId").val(id);
|
||||||
|
$('form').submit();
|
||||||
|
});
|
||||||
$('#dataConfirmModal').modal({show:true});
|
$('#dataConfirmModal').modal({show:true});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -55,7 +55,8 @@
|
|||||||
<a class="nav-link js-scroll-trigger" target="_blank" href="http://is.ulstu.ru">Сайт кафедры</a>
|
<a class="nav-link js-scroll-trigger" target="_blank" href="http://is.ulstu.ru">Сайт кафедры</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link js-scroll-trigger" target="_blank" th:href="@{'http://timetable.athene.tech?filter='+${currentUser}}">Расписание</a>
|
<a class="nav-link js-scroll-trigger" target="_blank"
|
||||||
|
th:href="@{'http://timetable.athene.tech?filter='+${currentUser}}">Расписание</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link js-scroll-trigger" target="_blank" href="https://kias.rfbr.ru/">КИАС РФФИ</a>
|
<a class="nav-link js-scroll-trigger" target="_blank" href="https://kias.rfbr.ru/">КИАС РФФИ</a>
|
||||||
@ -97,36 +98,53 @@
|
|||||||
<script src="/js/core.js"></script>
|
<script src="/js/core.js"></script>
|
||||||
<script src="/js/config.js"></script>
|
<script src="/js/config.js"></script>
|
||||||
<script src="/js/odin.js"></script>
|
<script src="/js/odin.js"></script>
|
||||||
|
<script th:inline="javascript">
|
||||||
|
|
||||||
|
/*<![CDATA[*/
|
||||||
|
var message = /*[[${flashMessage}]]*/ "";
|
||||||
|
if (message && message.length > 0) {
|
||||||
|
showFeedbackMessage(message, MessageTypesEnum.DANGER);
|
||||||
|
}
|
||||||
|
/*]]>*/
|
||||||
|
|
||||||
|
</script>
|
||||||
<th:block layout:fragment="scripts">
|
<th:block layout:fragment="scripts">
|
||||||
</th:block>
|
</th:block>
|
||||||
<!-- Yandex.Metrika counter -->
|
<!-- Yandex.Metrika counter -->
|
||||||
<script type="text/javascript" >
|
<script type="text/javascript">
|
||||||
(function (d, w, c) {
|
(function (d, w, c) {
|
||||||
(w[c] = w[c] || []).push(function() {
|
(w[c] = w[c] || []).push(function () {
|
||||||
try {
|
try {
|
||||||
w.yaCounter49387279 = new Ya.Metrika2({
|
w.yaCounter49387279 = new Ya.Metrika2({
|
||||||
id:49387279,
|
id: 49387279,
|
||||||
clickmap:true,
|
clickmap: true,
|
||||||
trackLinks:true,
|
trackLinks: true,
|
||||||
accurateTrackBounce:true,
|
accurateTrackBounce: true,
|
||||||
webvisor:true
|
webvisor: true
|
||||||
});
|
});
|
||||||
} catch(e) { }
|
} catch (e) {
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var n = d.getElementsByTagName("script")[0],
|
var n = d.getElementsByTagName("script")[0],
|
||||||
s = d.createElement("script"),
|
s = d.createElement("script"),
|
||||||
f = function () { n.parentNode.insertBefore(s, n); };
|
f = function () {
|
||||||
|
n.parentNode.insertBefore(s, n);
|
||||||
|
};
|
||||||
s.type = "text/javascript";
|
s.type = "text/javascript";
|
||||||
s.async = true;
|
s.async = true;
|
||||||
s.src = "https://mc.yandex.ru/metrika/tag.js";
|
s.src = "https://mc.yandex.ru/metrika/tag.js";
|
||||||
|
|
||||||
if (w.opera == "[object Opera]") {
|
if (w.opera == "[object Opera]") {
|
||||||
d.addEventListener("DOMContentLoaded", f, false);
|
d.addEventListener("DOMContentLoaded", f, false);
|
||||||
} else { f(); }
|
} else {
|
||||||
|
f();
|
||||||
|
}
|
||||||
})(document, window, "yandex_metrika_callbacks2");
|
})(document, window, "yandex_metrika_callbacks2");
|
||||||
</script>
|
</script>
|
||||||
<noscript><div><img src="https://mc.yandex.ru/watch/49387279" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
|
<noscript>
|
||||||
|
<div><img src="https://mc.yandex.ru/watch/49387279" style="position:absolute; left:-9999px;" alt=""/></div>
|
||||||
|
</noscript>
|
||||||
<!-- /Yandex.Metrika counter -->
|
<!-- /Yandex.Metrika counter -->
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
<span class="text-muted" th:text="${paper.authorsString}"/>
|
<span class="text-muted" th:text="${paper.authorsString}"/>
|
||||||
</a>
|
</a>
|
||||||
<input class="id-class" type="hidden" th:value="${paper.id}"/>
|
<input class="id-class" type="hidden" th:value="${paper.id}"/>
|
||||||
<a class="remove-paper pull-right d-none" th:href="@{'/papers/delete/'+${paper.id}}"
|
<a class="remove-paper pull-right d-none" href="#" data-confirm="Удалить статью?">
|
||||||
data-confirm="Удалить статью?">
|
|
||||||
<i class="fa fa-trash" aria-hidden="true"></i>
|
<i class="fa fa-trash" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user