Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
e889fb90
Commit
e889fb90
authored
Oct 20, 2015
by
Matija Obreza
Browse files
GeoRegion blurb
parent
04ede25e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/servlet/controller/GeoRegionController.java
View file @
e889fb90
...
...
@@ -6,6 +6,7 @@ import java.util.stream.Collectors;
import
org.genesys2.server.model.impl.Country
;
import
org.genesys2.server.model.impl.GeoRegion
;
import
org.genesys2.server.persistence.domain.CountryRepository
;
import
org.genesys2.server.service.ContentService
;
import
org.genesys2.server.service.GeoRegionService
;
import
org.genesys2.spring.ResourceNotFoundException
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -13,6 +14,7 @@ import org.springframework.stereotype.Controller;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
@Controller
...
...
@@ -25,15 +27,17 @@ public class GeoRegionController extends BaseController {
@Autowired
CountryRepository
countryRepository
;
@Autowired
private
ContentService
contentService
;
@RequestMapping
public
String
viewAll
()
{
public
String
list
()
{
return
"/region/index"
;
}
@RequestMapping
(
"/{isoCode}"
)
public
String
view
Region
(
ModelMap
model
,
@PathVariable
(
value
=
"isoCode"
)
String
code
)
{
public
String
view
(
ModelMap
model
,
@PathVariable
(
value
=
"isoCode"
)
String
code
)
{
GeoRegion
geoRegion
=
geoRegionService
.
find
(
code
);
...
...
@@ -46,6 +50,7 @@ public class GeoRegionController extends BaseController {
Country
.
sort
(
countryList
,
getLocale
());
model
.
addAttribute
(
"region"
,
geoRegion
);
model
.
addAttribute
(
"blurp"
,
contentService
.
getArticle
(
geoRegion
,
"blurp"
,
getLocale
()));
List
<
GeoRegion
>
subRegions
=
geoRegionService
.
getChildren
(
geoRegion
.
getIsoCode
());
GeoRegion
.
sort
(
subRegions
,
getLocale
());
model
.
addAttribute
(
"subRegions"
,
subRegions
);
...
...
@@ -58,4 +63,27 @@ public class GeoRegionController extends BaseController {
private
boolean
isCurrent
(
Country
country
)
{
return
country
.
isCurrent
();
}
@RequestMapping
(
"/{isoCode}/edit"
)
public
String
edit
(
ModelMap
model
,
@PathVariable
(
value
=
"isoCode"
)
String
code
)
{
view
(
model
,
code
);
return
"/region/edit"
;
}
@RequestMapping
(
"/{isoCode}/update"
)
public
String
update
(
ModelMap
model
,
@PathVariable
(
value
=
"isoCode"
)
String
code
,
@RequestParam
(
"blurp"
)
String
body
,
@RequestParam
(
value
=
"summary"
,
required
=
false
)
String
summary
)
{
_logger
.
debug
(
"Updating region "
+
code
);
final
GeoRegion
region
=
geoRegionService
.
find
(
code
);
if
(
region
==
null
)
{
throw
new
ResourceNotFoundException
();
}
contentService
.
updateArticle
(
region
,
"blurp"
,
null
,
body
,
summary
,
getLocale
());
return
"redirect:/geo/regions/"
+
code
;
}
}
src/main/webapp/WEB-INF/jsp/region/edit.jsp
0 → 100644
View file @
e889fb90
<!DOCTYPE html>
<%@include
file=
"/WEB-INF/jsp/init.jsp"
%>
<html>
<head>
<title><c:out
value=
"
${
region
.
getName
(
pageContext
.
response
.
locale
)
}
"
/></title>
</head>
<body>
<h1>
<c:out
value=
"
${
region
.
getName
(
pageContext
.
response
.
locale
)
}
"
/>
</h1>
<form
role=
"form"
class=
"form-horizontal"
action=
"
<c:url
value=
"/geo/regions/${region.isoCode}/update"
/>
"
method=
"post"
>
<div
class=
"form-group"
>
<label
for=
"blurp-body"
class=
"col-lg-12 control-label"
><spring:message
code=
"blurp.blurp-body"
/></label>
<div
class=
"controls col-lg-12"
>
<textarea
id=
"blurp-body"
name=
"blurp"
class=
"span9 required html-editor"
>
<c:out
value=
"
${
blurp
.
body
}
"
/>
</textarea>
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"crop-summary"
class=
"col-lg-12 control-label"
><spring:message
code=
"crop.summary"
/></label>
<div
class=
"controls col-lg-12"
>
<textarea
id=
"crop-summary"
name=
"summary"
class=
"span9 required html-editor"
>
<c:out
value=
"
${
blurp
.
summary
}
"
/>
</textarea>
</div>
</div>
<input
type=
"submit"
value=
"
<spring:message
code=
"save"
/>
"
class=
"btn btn-primary"
/>
<a
href=
"
<c:url
value=
"/geo/regions/${region.isoCode}"
/>
"
class=
"btn btn-default"
>
<spring:message
code=
"cancel"
/>
</a>
<!-- CSRF protection -->
<input
type=
"hidden"
name=
"${_csrf.parameterName}"
value=
"${_csrf.token}"
/>
</form>
<content
tag=
"javascript"
>
<script
type=
"text/javascript"
>
<local:tinyMCE
selector=
".html-editor"
/>
</script>
</content>
</body>
</html>
\ No newline at end of file
src/main/webapp/WEB-INF/jsp/region/region.jsp
View file @
e889fb90
...
...
@@ -7,9 +7,14 @@
<title><c:out
value=
"
${
region
.
getName
(
pageContext
.
response
.
locale
)
}
"
/></title>
</head>
<body>
<h1>
<c:out
value=
"
${
region
.
getName
(
pageContext
.
response
.
locale
)
}
"
/>
</h1>
<div
class=
"informative-h1 row"
>
<div
class=
"col-md-12 col-sm-12"
>
<h1>
<c:out
value=
"
${
region
.
getName
(
pageContext
.
response
.
locale
)
}
"
/>
</h1>
<c:out
value=
"
${
blurp
.
summary
}
"
escapeXml=
"false"
/>
</div>
</div>
<div
class=
"results main-col-header"
>
<h4>
...
...
@@ -25,6 +30,18 @@
</h4>
</div>
<security:authorize
access=
"hasRole('ADMINISTRATOR') or hasRole('CONTENTMANAGER') or hasPermission(#region, 'ADMINISTRATION')"
>
<a
href=
"
<c:url
value=
"/geo/regions/${region.isoCode}/edit"
/>
"
class=
"close"
>
<spring:message
code=
"edit"
/>
</a>
</security:authorize>
<c:if
test=
"
${
blurp
ne
null
}
"
>
<%@include
file=
"/WEB-INF/jsp/content/include/blurp-display.jsp"
%>
</c:if>
<c:if
test=
"
${
subRegions
ne
null
and
subRegions
.
size
()
gt
0
}
"
>
<h3><spring:message
code=
"region.regions-in-region"
arguments=
"
${
region
.
getName
(
pageContext
.
response
.
locale
)
}
"
/></h3>
<ul
class=
"funny-list"
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment