Skip to content

Commit eb8a9a4

Browse files
committed
Limit ability for specifying series price only to paid users.
Follow-up to #663
1 parent a9fbbc7 commit eb8a9a4

File tree

7 files changed

+16
-3
lines changed

7 files changed

+16
-3
lines changed

NEWS.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
- (functionality) add support for specifying Solovyov catalog numbers
2222
- (functionality) add support for specifying Zagorski catalog numbers
2323
- (functionality) user may specify how many stamps from a series in his/her collection
24-
- (functionality) user may specify a price that he/she paid for a series
24+
- (functionality) paid users may specify a price that he/she paid for a series
2525

2626
0.3
2727
- (functionality) implemented possibility to user to add series to his collection

src/main/java/ru/mystamps/web/support/spring/security/Authority.java

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public final class Authority {
2626
public static final GrantedAuthority ADD_COMMENTS_TO_SERIES = new SimpleGrantedAuthority(StringAuthority.ADD_COMMENTS_TO_SERIES);
2727
public static final GrantedAuthority ADD_IMAGES_TO_SERIES = new SimpleGrantedAuthority(StringAuthority.ADD_IMAGES_TO_SERIES);
2828
public static final GrantedAuthority ADD_PARTICIPANT = new SimpleGrantedAuthority(StringAuthority.ADD_PARTICIPANT);
29+
public static final GrantedAuthority ADD_SERIES_PRICE = new SimpleGrantedAuthority(StringAuthority.ADD_SERIES_PRICE);
2930
public static final GrantedAuthority ADD_SERIES_SALES = new SimpleGrantedAuthority(StringAuthority.ADD_SERIES_SALES);
3031
public static final GrantedAuthority CREATE_CATEGORY = new SimpleGrantedAuthority(StringAuthority.CREATE_CATEGORY);
3132
public static final GrantedAuthority CREATE_COUNTRY = new SimpleGrantedAuthority(StringAuthority.CREATE_COUNTRY);

src/main/java/ru/mystamps/web/support/spring/security/CustomUserDetailsService.java

+4
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,17 @@ private static Collection<? extends GrantedAuthority> getAuthorities(UserDetails
7979
authorities.add(Authority.ADD_COMMENTS_TO_SERIES);
8080
authorities.add(Authority.ADD_IMAGES_TO_SERIES);
8181
authorities.add(Authority.ADD_PARTICIPANT);
82+
authorities.add(Authority.ADD_SERIES_PRICE);
8283
authorities.add(Authority.ADD_SERIES_SALES);
8384
authorities.add(Authority.DOWNLOAD_IMAGE);
8485
authorities.add(Authority.IMPORT_SERIES);
8586
authorities.add(Authority.MANAGE_TOGGLZ);
8687
authorities.add(Authority.VIEW_DAILY_STATS);
8788
authorities.add(Authority.VIEW_SERIES_SALES);
8889
authorities.add(Authority.VIEW_SITE_EVENTS);
90+
91+
} else if (userDetails.isPaidUser()) {
92+
authorities.add(Authority.ADD_SERIES_PRICE);
8993
}
9094

9195
return authorities;

src/main/java/ru/mystamps/web/support/spring/security/StringAuthority.java

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public final class StringAuthority {
2222
public static final String ADD_COMMENTS_TO_SERIES = "ADD_COMMENTS_TO_SERIES";
2323
public static final String ADD_IMAGES_TO_SERIES = "ADD_IMAGES_TO_SERIES";
2424
public static final String ADD_PARTICIPANT = "ADD_PARTICIPANT";
25+
public static final String ADD_SERIES_PRICE = "ADD_SERIES_PRICE";
2526
public static final String ADD_SERIES_SALES = "ADD_SERIES_SALES";
2627
public static final String CREATE_CATEGORY = "CREATE_CATEGORY";
2728
public static final String CREATE_COUNTRY = "CREATE_COUNTRY";

src/main/resources/ru/mystamps/i18n/Messages.properties

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ t_yes = Yes
136136
t_no = No
137137
t_series_not_in_collection = Series isn't part of your collection
138138
t_i_have = I have
139+
t_only_for_paid_users = Only for paid users
139140
t_i_bought_for = I bought for
140141
t_out_of_n_stamps = out of {0} stamps
141142
t_series_in_collection = Series is part of your collection

src/main/resources/ru/mystamps/i18n/Messages_ru.properties

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ t_yes = Да
135135
t_no = Нет
136136
t_series_not_in_collection = Этой серии нет в вашей коллекции
137137
t_i_have = У меня есть
138+
t_only_for_paid_users = Только для платных пользователей
138139
t_i_bought_for = Я купил за
139140
t_out_of_n_stamps = из {0} марок
140141
t_series_in_collection = Эта серия есть в вашей коллекции

src/main/webapp/WEB-INF/views/series/info.html

+7-2
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,21 @@
369369
th:text="${error}"></span>
370370
</p>
371371
/*/-->
372-
<p th:with="price_msg=#{t_price}">
372+
<p th:with="price_msg=#{t_price},paidUser=${#authorization.expression('hasAuthority(''ADD_SERIES_PRICE'')')}"
373+
th:attrappend="title=${paidUser ? null : '__#{t_only_for_paid_users}__'}">
374+
373375
<span th:text="#{t_i_bought_for}" th:remove="tag">I bought for</span>
374376
<input id="paid-price"
375377
type="text"
376378
size="5"
377379
placeholder="price"
378380
th:placeholder="${#strings.unCapitalize(price_msg)}"
379381
th:field="*{price}"
382+
th:disabled="${paidUser ? null : 'disabled'}"
380383
/>
381-
<select id="paid-currency" th:field="*{currency}">
384+
<select id="paid-currency"
385+
th:field="*{currency}"
386+
th:disabled="${paidUser ? null : 'disabled'}">
382387
<option value=""></option>
383388
<option value="USD">USD</option>
384389
<option value="EUR">EUR</option>

0 commit comments

Comments
 (0)