- Timestamp:
- 09/03/21 18:34:05 (3 years ago)
- Branches:
- master
- Children:
- 5306751
- Parents:
- f8007b3
- Location:
- src/main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/it/finki/charitable/controller/DonationPostController.java
rf8007b3 r194776a 172 172 173 173 DonationPost post = donationPostService.getById(postid); 174 FundsCollected funds = new FundsCollected(" online", amount);174 FundsCollected funds = new FundsCollected("Online donation", amount); 175 175 fundsCollectedService.save(funds); 176 176 -
src/main/java/it/finki/charitable/controller/UserProfileController.java
rf8007b3 r194776a 105 105 } 106 106 107 @RequestMapping( "/addFunds")107 @RequestMapping(value = "/addFunds", method = RequestMethod.POST) 108 108 public String addFunds(@RequestParam Long postid, 109 109 @RequestParam String type, … … 111 111 112 112 DonationPost post = donationPostService.getById(postid); 113 FundsCollected funds = new FundsCollected(type, amount); 114 fundsCollectedService.save(funds); 115 116 post.getFundsCollected().add(funds); 117 donationPostService.save(post); 113 if(post.getUser().getUsername().equals(SecurityContextHolder.getContext().getAuthentication().getName())) { 114 FundsCollected funds = new FundsCollected(type, amount); 115 fundsCollectedService.save(funds); 116 post.getFundsCollected().add(funds); 117 donationPostService.save(post); 118 } 118 119 return "redirect:/myPosts"; 119 120 } -
src/main/resources/templates/myProfile.html
rf8007b3 r194776a 241 241 <a class="btn btn-sm btn-outline-secondary" 242 242 th:href="@{/post(postid=${post.id})}">Open</a> 243 <button type="button" class="btn btn- primary" data-bs-toggle="modal"244 th:data-bs-target="'# a' + ${post.id}">243 <button type="button" class="btn btn-sm btn-success" data-bs-toggle="modal" 244 th:data-bs-target="'#m' + ${post.id}"> 245 245 Add collected funds 246 246 </button> … … 255 255 </div> 256 256 </div> 257 <div class="modal fade" th:id="' a' + ${post.id}" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"257 <div class="modal fade" th:id="'m' + ${post.id}" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" 258 258 aria-labelledby="staticBackdropLabel" aria-hidden="true"> 259 259 <div class="modal-dialog modal-dialog-centered"> … … 267 267 <form th:id="'my-form' + ${post.id}" th:action="@{/addFunds(postid=${post.id})}" method="post"> 268 268 <div class="row"> 269 <div class="col"> 270 <select class="input-group-text" name="type"> 269 <div class="col-md-6"> 270 <label for="type" class="form-label">Type</label> 271 <select id="type" class="form-select" name="type"> 271 272 <option value="Bank donation">Bank donation</option> 272 273 <option value="Phone donation">Phone donation</option> 273 274 </select> 274 275 </div> 275 <div class="col"> 276 <input type="number" class="input-group-text" name="amount"> 276 <div class="col-md-6"> 277 <label for="amount" class="form-label">Amount</label> 278 <input id="amount" type="number" class="form-control" name="amount"> 277 279 </div> 278 280 </div>
Note:
See TracChangeset
for help on using the changeset viewer.