Changeset 3fe36de in Git for src/main/java


Ignore:
Timestamp:
02/09/22 03:14:08 (3 years ago)
Author:
Petar Partaloski <ppartaloski@…>
Branches:
main
Children:
967b414
Parents:
c02189f
Message:

Added User profiles, improved clarity, improved UI

Location:
src/main/java/com/wediscussmovies/project
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/wediscussmovies/project/configuration/SecurityConfig.java

    rc02189f r3fe36de  
    2929        http.csrf().disable()
    3030                .authorizeRequests()
    31                 .antMatchers("/movies","/movies/**/","/actors","/persons/**/","/directors","/discussions","/discussions/**/","/discussions/all/**/","/replies","/register","/genres", "/css/**","/img/**", "/js/**").permitAll()
     31                .antMatchers("/movies","/movies/**/","/actors","/persons/**/","/directors","/discussions","/profiles/**","/discussions/**/","/discussions/all/**/","/replies","/register","/genres", "/css/**","/img/**", "/js/**").permitAll()
    3232                .anyRequest()
    3333                .authenticated()
  • src/main/java/com/wediscussmovies/project/model/Movie.java

    rc02189f r3fe36de  
    9595
    9696
    97 
     97    public String getShortTitle(){
     98        int to = 20;
     99        if (title.length() < to)
     100            to = title.length();
     101        if(to<20)
     102            return title;
     103        return title.substring(0, to) + "...";
     104    }
    98105
    99106
  • src/main/java/com/wediscussmovies/project/model/Person.java

    rc02189f r3fe36de  
    9292    }
    9393
     94    public boolean hasGradeFromUser(User user){
     95        for(PersonRates p: personRates){
     96            if(p.getUser().getUserId() == user.getUserId())
     97                return true;
     98        }
     99        return false;
     100    }
     101
    94102}
  • src/main/java/com/wediscussmovies/project/service/UserService.java

    rc02189f r3fe36de  
    1010     User findByUsername(String username);
    1111     User register(String email, String username, String password, String confirmPassword, String name, String surname);
     12
     13    User findById(Integer id);
    1214}
  • src/main/java/com/wediscussmovies/project/service/impl/UserServiceImpl.java

    rc02189f r3fe36de  
    4848
    4949    @Override
     50    public User findById(Integer id) {
     51        return userRepository.findById(id).orElseThrow(() -> new UserNotExistException(id.toString()));
     52    }
     53
     54    @Override
    5055    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    5156        return this.findByUsername(username);
  • src/main/java/com/wediscussmovies/project/web/controller/PersonController.java

    rc02189f r3fe36de  
    5555        //Error handling, could be null!!!!!!!!!
    5656        model.addAttribute("person", person);
    57 
     57        addModelPropertiesForUser(model);
    5858        model.addAttribute("contentTemplate", "personShow");
    5959        return "template";
  • src/main/java/com/wediscussmovies/project/web/controller/UsersController.java

    rc02189f r3fe36de  
    1111import org.springframework.stereotype.Controller;
    1212import org.springframework.ui.Model;
    13 import org.springframework.web.bind.annotation.GetMapping;
    14 import org.springframework.web.bind.annotation.PostMapping;
    15 import org.springframework.web.bind.annotation.RequestMapping;
    16 import org.springframework.web.bind.annotation.RequestParam;
     13import org.springframework.web.bind.annotation.*;
    1714
    1815import java.util.ArrayList;
     
    4239            return "redirect:/register?error=" + exception.getMessage();
    4340        }
     41    }
     42    @GetMapping("/profiles/{id}")
     43    public String getProfilePage(@PathVariable Integer id, Model model){
     44        model.addAttribute("user",userService.findById(id));
     45        model.addAttribute("contentTemplate","usersShow");
     46        return "template";
    4447    }
    4548    @GetMapping("/register")
Note: See TracChangeset for help on using the changeset viewer.