Commit bc1517d2 authored by Matija Obreza's avatar Matija Obreza
Browse files

List all articles for admin/contentmanager roles

parent 08181062
...@@ -20,6 +20,8 @@ import org.genesys2.server.model.impl.Article; ...@@ -20,6 +20,8 @@ import org.genesys2.server.model.impl.Article;
import org.genesys2.server.service.ContentService; import org.genesys2.server.service.ContentService;
import org.genesys2.spring.ResourceNotFoundException; import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
...@@ -35,6 +37,13 @@ public class ArticleController extends BaseController { ...@@ -35,6 +37,13 @@ public class ArticleController extends BaseController {
@Autowired @Autowired
private ContentService contentService; private ContentService contentService;
@RequestMapping
@PreAuthorize("hasRole('ADMINISTRATOR') or hasRole('CONTENTMANAGER')")
public String list(ModelMap model, @RequestParam(value = "page", defaultValue = "1") int page) {
model.addAttribute("pagedData", contentService.listArticles(new PageRequest(page - 1, 50, new Sort("slug"))));
return "/content/index";
}
@RequestMapping("{url:.+}") @RequestMapping("{url:.+}")
public String view(ModelMap model, @PathVariable(value = "url") String slug) { public String view(ModelMap model, @PathVariable(value = "url") String slug) {
_logger.debug("Viewing article " + slug); _logger.debug("Viewing article " + slug);
......
...@@ -469,3 +469,8 @@ stats.number-of-institutes={0} Institutes ...@@ -469,3 +469,8 @@ stats.number-of-institutes={0} Institutes
stats.number-of-accessions={0} Accessions stats.number-of-accessions={0} Accessions
navigate.back=Back navigate.back=Back
content.page.list.title=Article list
article.lang=Language
article.classPk=Object
...@@ -44,9 +44,9 @@ captcha.publicKey=6Lf7oucSAAAAAGaS7ObroY2bNgCqMTmpyFVu7wMW ...@@ -44,9 +44,9 @@ captcha.publicKey=6Lf7oucSAAAAAGaS7ObroY2bNgCqMTmpyFVu7wMW
download.files.dir=./data/ download.files.dir=./data/
# ITPGRFA Easy-SMTA account (if you have one) # ITPGRFA Easy-SMTA account (if you have one)
itpgrfa.easysmta.url= itpgrfa.easysmta.url=https://mls.planttreaty.org/itt/index.php?r=extsys/userinfo
itpgrfa.easysmta.username= itpgrfa.easysmta.username=genesys
itpgrfa.easysmta.password= itpgrfa.easysmta.password=t3st4r0ss4
# GA Account # GA Account
google.analytics.account= google.analytics.account=
......
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<html>
<head>
<title><spring:message code="content.page.list.title" /></title>
</head>
<body>
<h1>
<spring:message code="content.page.list.title" />
</h1>
<div class="main-col-header clearfix">
<div class="nav-header pull-left">
<div class="results"><spring:message code="paged.totalElements" arguments="${pagedData.totalElements}" /></div>
<div class="pagination">
<spring:message code="paged.pageOfPages" arguments="${pagedData.number+1},${pagedData.totalPages}" />
<a class="${pagedData.number eq 0 ? 'disabled' :''}" href="?page=${pagedData.number eq 0 ? 1 : pagedData.number}"><spring:message code="pagination.previous-page" /></a> <a href="?page=${pagedData.number + 2}"><spring:message code="pagination.next-page" /></a>
</div>
</div>
</div>
<table class="">
<thead>
<tr>
<td><spring:message code="article.slug" /></td>
<td><spring:message code="article.lang" /></td>
<td><spring:message code="article.classPk" /></td>
<td><spring:message code="article.title" /></td>
</tr>
</thead>
<tbody>
<c:forEach items="${pagedData.content}" var="article" varStatus="status">
<tr class="${status.count % 2 == 0 ? 'even' : 'odd'}">
<td><a href="<c:url value="/content/${article.slug}/edit" />">${article.slug}</a></td>
<td>${article.lang}</td>
<td>${article.classPk.className} ${article.targetId}</td>
<td>${article.title}</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
\ No newline at end of file
...@@ -11,12 +11,16 @@ ...@@ -11,12 +11,16 @@
<spring:message code="user.page.list.title" /> <spring:message code="user.page.list.title" />
</h1> </h1>
<div class="nav-header"> <div class="main-col-header clearfix">
<spring:message code="paged.totalElements" arguments="${pagedData.totalElements}" /> <div class="nav-header pull-left">
<br /> <div class="results"><spring:message code="paged.totalElements" arguments="${pagedData.totalElements}" /></div>
<spring:message code="paged.pageOfPages" arguments="${pagedData.number+1},${pagedData.totalPages}" /> <div class="pagination">
<a class="${pagedData.number eq 0 ? 'disabled' :''}" href="?page=${pagedData.number eq 0 ? 1 : pagedData.number}"><spring:message code="pagination.previous-page" /></a> <a href="?page=${pagedData.number + 2}"><spring:message code="pagination.next-page" /></a> <spring:message code="paged.pageOfPages" arguments="${pagedData.number+1},${pagedData.totalPages}" />
<a class="${pagedData.number eq 0 ? 'disabled' :''}" href="?page=${pagedData.number eq 0 ? 1 : pagedData.number}"><spring:message code="pagination.previous-page" /></a> <a href="?page=${pagedData.number + 2}"><spring:message code="pagination.next-page" /></a>
</div>
</div> </div>
</div>
<table class="funny-list"> <table class="funny-list">
<c:forEach items="${pagedData.content}" var="user" varStatus="status"> <c:forEach items="${pagedData.content}" var="user" varStatus="status">
<tr class="clearfix ${status.count % 2 == 0 ? 'even' : 'odd'}"> <tr class="clearfix ${status.count % 2 == 0 ? 'even' : 'odd'}">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment