Changeset 42d565b in Git for src/main/java


Ignore:
Timestamp:
02/06/22 21:38:16 (3 years ago)
Author:
GitHub <noreply@…>
Branches:
main
Children:
7f36551
Parents:
5b447b0 (diff), 2efe93e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Mato-77 <56981531+Mato-77@…> (02/06/22 21:38:16)
git-committer:
GitHub <noreply@…> (02/06/22 21:38:16)
Message:

Merge pull request #1 from partaloski/master

Fixed and added a better front end, improved clarity

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

Legend:

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

    r5b447b0 r42d565b  
    55import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
    66import org.springframework.security.config.annotation.web.builders.HttpSecurity;
     7import org.springframework.security.config.annotation.web.builders.WebSecurity;
    78import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
    89
     
    1516    }
    1617
     18    @Override
     19    public void configure(WebSecurity web) throws Exception {
     20        web.ignoring().antMatchers("/*.jpg");
     21        web.ignoring().antMatchers("/*.png");
     22        web.ignoring().antMatchers("/*.css");
     23        web.ignoring().antMatchers("/*.js");
     24    }
    1725
    1826    @Override
     
    2129        http.csrf().disable()
    2230                .authorizeRequests()
    23                 .antMatchers("/movies","/actors","/directors","/discussions","/replies","/register","/genres").permitAll()
     31                .antMatchers("/movies","/movies/**/","/actors","/persons/**/","/directors","/discussions","/discussions/**/","/discussions/all/**/","/replies","/register","/genres", "/css/**", "/js/**").permitAll()
    2432                .anyRequest()
    2533                .authenticated()
  • src/main/java/com/wediscussmovies/project/model/Movie.java

    r5b447b0 r42d565b  
    66import com.wediscussmovies.project.model.relation.MovieRates;
    77import lombok.Data;
     8import org.hibernate.annotations.Fetch;
    89
    910import javax.persistence.*;
     
    3738    private Double imdbRating;
    3839
    39     @OneToMany(mappedBy = "movie")
     40    @OneToMany(mappedBy = "movie", fetch = FetchType.LAZY)
    4041    private Collection<MovieActors> actors;
    4142    @OneToMany(mappedBy = "movie")
  • src/main/java/com/wediscussmovies/project/web/controller/MovieController.java

    r5b447b0 r42d565b  
    11package com.wediscussmovies.project.web.controller;
    22
     3import com.wediscussmovies.project.LoggedUser;
    34import com.wediscussmovies.project.model.Movie;
    45import com.wediscussmovies.project.model.Person;
     
    1920import java.sql.Date;
    2021import java.time.LocalDate;
     22import java.util.ArrayList;
    2123import java.util.List;
    2224
     
    5355          model.addAttribute("user",user);
    5456        }
    55 
     57        List<Movie> movieList = movies;
     58        List<List<Movie>> movie_rows = new ArrayList<>();
     59        for(int i=0; i<movieList.size(); i+=4){
     60            int j = i+4;
     61            if(j>movieList.size())
     62                j=movieList.size();
     63            movie_rows.add(movieList.subList(i, j));
     64        }
    5665        model.addAttribute("movies", movies);
     66        model.addAttribute("movie_rows", movie_rows);
    5767        model.addAttribute("contentTemplate", "moviesList");
    5868        if (error != null && !error.equals(" "))
     
    6171    }
    6272
     73    @GetMapping("/{id}")
     74    public String getMovie(@PathVariable Integer id, Model model){
     75        model.addAttribute("movie", movieService.findById(id));
     76
     77        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
     78        if (!(auth instanceof AnonymousAuthenticationToken)){
     79            UserDetails userDetails = (UserDetails) auth.getPrincipal();
     80            User user = (User) userDetails;
     81            model.addAttribute("likedMovies",this.movieService.findLikedMoviesByUser(user));
     82            model.addAttribute("user",user);
     83        }
     84
     85        model.addAttribute("contentTemplate", "movieShow");
     86        return "template";
     87    }
    6388
    6489    @GetMapping("/add")
  • src/main/java/com/wediscussmovies/project/web/controller/PersonController.java

    r5b447b0 r42d565b  
    4545        model.addAttribute("persons", persons);
    4646        model.addAttribute("contentTemplate", "personsList");
     47        return "template";
     48    }
     49
     50    @GetMapping("/persons/{id}")
     51    public String getPerson(@PathVariable Integer id, Model model){
     52        Person person = personService.findById(id);
     53        //Error handling, could be null!!!!!!!!!
     54        model.addAttribute("person", person);
     55
     56        model.addAttribute("contentTemplate", "personShow");
    4757        return "template";
    4858    }
  • src/main/java/com/wediscussmovies/project/web/controller/UsersController.java

    r5b447b0 r42d565b  
    33
    44import com.wediscussmovies.project.LoggedUser;
     5import com.wediscussmovies.project.model.Movie;
    56import com.wediscussmovies.project.model.exception.InvalidArgumentsException;
    67import com.wediscussmovies.project.model.exception.PasswordsDoNotMatchException;
     
    1314import org.springframework.web.bind.annotation.RequestMapping;
    1415import org.springframework.web.bind.annotation.RequestParam;
     16
     17import java.util.ArrayList;
     18import java.util.List;
    1519
    1620@Controller
     
    5963    @GetMapping("/favoriteList")
    6064    public String getFavoriteList(Model model){
    61         model.addAttribute("movies",this.movieService.findLikedMoviesByUser(LoggedUser.getLoggedUser()));
     65        List<Movie> movieList = this.movieService.findLikedMoviesByUser(LoggedUser.getLoggedUser());
     66        List<List<Movie>> movie_rows = new ArrayList<>();
     67        for(int i=0; i<movieList.size(); i+=4){
     68            int j = i+4;
     69            if(j>movieList.size())
     70                j= movieList.size();
     71            movie_rows.add(movieList.subList(i, j));
     72        }
     73        model.addAttribute("movie_rows", movie_rows);
    6274        model.addAttribute("contentTemplate","favoriteList");
    6375        return "template";
Note: See TracChangeset for help on using the changeset viewer.