45
45
import ru .mystamps .web .Url ;
46
46
import ru .mystamps .web .entity .Collection ;
47
47
import ru .mystamps .web .entity .User ;
48
+ import ru .mystamps .web .model .AddImageForm ;
48
49
import ru .mystamps .web .model .AddSeriesForm ;
49
50
import ru .mystamps .web .model .AddSeriesForm .ScottCatalogChecks ;
50
51
import ru .mystamps .web .model .AddSeriesForm .GibbonsCatalogChecks ;
@@ -151,6 +152,7 @@ public String showInfo(@PathVariable("id") Series series, Model model, User curr
151
152
throw new NotFoundException ();
152
153
}
153
154
155
+ model .addAttribute ("addImageForm" , new AddImageForm ());
154
156
model .addAttribute ("series" , series );
155
157
model .addAttribute ("michelNumbers" , CatalogUtils .toShortForm (series .getMichel ()));
156
158
model .addAttribute ("scottNumbers" , CatalogUtils .toShortForm (series .getScott ()));
@@ -165,6 +167,40 @@ public String showInfo(@PathVariable("id") Series series, Model model, User curr
165
167
return "series/info" ;
166
168
}
167
169
170
+ @ RequestMapping (value = Url .INFO_SERIES_PAGE , method = RequestMethod .POST )
171
+ public String processImage (
172
+ @ Validated ({ Default .class , AddImageForm .ImageChecks .class }) AddImageForm form ,
173
+ BindingResult result ,
174
+ @ PathVariable ("id" ) Series series ,
175
+ Model model ,
176
+ User currentUser ) {
177
+
178
+ model .addAttribute ("series" , series );
179
+ model .addAttribute ("michelNumbers" , CatalogUtils .toShortForm (series .getMichel ()));
180
+ model .addAttribute ("scottNumbers" , CatalogUtils .toShortForm (series .getScott ()));
181
+ model .addAttribute ("yvertNumbers" , CatalogUtils .toShortForm (series .getYvert ()));
182
+ model .addAttribute ("gibbonsNumbers" , CatalogUtils .toShortForm (series .getGibbons ()));
183
+
184
+ model .addAttribute (
185
+ "isSeriesInCollection" ,
186
+ collectionService .isSeriesInCollection (currentUser , series )
187
+ );
188
+
189
+ if (result .hasErrors ()) {
190
+ // don't try to re-display file upload field
191
+ form .setImage (null );
192
+ return "series/info" ;
193
+ }
194
+
195
+ if (series == null ) {
196
+ throw new NotFoundException ();
197
+ }
198
+
199
+ seriesService .addImageToSeries (form , series );
200
+
201
+ return "series/info" ;
202
+ }
203
+
168
204
@ RequestMapping (
169
205
value = Url .INFO_SERIES_PAGE ,
170
206
method = RequestMethod .POST ,
0 commit comments