Changeset 59a8941


Ignore:
Timestamp:
02/16/23 13:45:55 (17 months ago)
Author:
SazdovaEkaterina <sazdovaekaterina@…>
Branches:
main
Children:
50f2c2a
Parents:
a762b3a (diff), da44aef (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.
Message:

merge login and register into branch

Location:
Prototype Application/Paw5/src/main
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Adopter.java

    ra762b3a r59a8941  
    4141
    4242    @Column(name = "verified_by_employee")
    43     private int verifiedByEmployeeId;
     43    private Integer verifiedByEmployeeId;
    4444
    4545    public Adopter(LocalDate dateCreated, String name, String email, String password, String telephone,
    4646                   FreeTime freeTime, Funds funds, boolean hasOtherPets, boolean hasKids, Housing housing,
    47                    PhysicalActivity physicalActivity, boolean willFoster, boolean verified, int verifiedByEmployeeId) {
     47                   PhysicalActivity physicalActivity, boolean willFoster, boolean verified) {
    4848        super(dateCreated, name, email, password, telephone);
    4949        this.freeTime = freeTime;
     
    5555        this.willFoster = willFoster;
    5656        this.verified = verified;
    57         this.verifiedByEmployeeId = verifiedByEmployeeId;
    5857    }
    5958
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Employee.java

    ra762b3a r59a8941  
    1616
    1717    @Column(name = "id_shelter", nullable = false)
    18     private int shelterId;
     18    private Integer shelterId;
    1919
    2020    @Column(name = "is_verified", nullable = false)
     
    2222
    2323    @Column(name = "verified_by_admin")
    24     private int verifiedByAdminId;
     24    private Integer verifiedByAdminId;
    2525
    2626    public Employee(LocalDate dateCreated, String name, String email, String password, String telephone,
    27                     String position, int shelterId, boolean verified, int verifiedByAdminId) {
     27                    String position, int shelterId, boolean verified) {
    2828        super(dateCreated, name, email, password, telephone);
    2929        this.position = position;
    3030        this.shelterId = shelterId;
    3131        this.verified = verified;
    32         this.verifiedByAdminId = verifiedByAdminId;
    3332    }
    3433
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Shelter.java

    ra762b3a r59a8941  
    2121
    2222    @Column(name = "id_organisation")
    23     private int organisationId;
     23    private Integer organisationId;
    2424
    2525    @Column(name = "name_shelter", nullable = false, length = 100)
     
    2929    private String email;
    3030
    31     public Shelter(String address, String telephone, int organisationId, String name, String email) {
     31    public Shelter(String address, String telephone, Integer organisationId, String name, String email) {
    3232        this.address = address;
    3333        this.telephone = telephone;
  • Prototype Application/Paw5/src/main/java/finki/paw5/repository/AdopterRepository.java

    ra762b3a r59a8941  
    55import org.springframework.stereotype.Repository;
    66
     7
    78@Repository
    89public interface AdopterRepository extends JpaRepository<Adopter, Integer> {
  • Prototype Application/Paw5/src/main/java/finki/paw5/repository/EmployeeRepository.java

    ra762b3a r59a8941  
    22
    33import finki.paw5.model.entities.Employee;
     4import finki.paw5.model.entities.Shelter;
    45import org.springframework.data.jpa.repository.JpaRepository;
    56import org.springframework.stereotype.Repository;
     7
     8import java.util.List;
    69
    710@Repository
  • Prototype Application/Paw5/src/main/java/finki/paw5/repository/ShelterRepository.java

    ra762b3a r59a8941  
    55import org.springframework.stereotype.Repository;
    66
     7import java.util.List;
     8
    79@Repository
    810public interface ShelterRepository extends JpaRepository<Shelter, Integer> {
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/AuthService.java

    ra762b3a r59a8941  
    44import finki.paw5.model.entities.Employee;
    55import finki.paw5.model.entities.User;
    6 
    7 import java.util.Optional;
     6import finki.paw5.model.enumerations.FreeTime;
     7import finki.paw5.model.enumerations.Funds;
     8import finki.paw5.model.enumerations.Housing;
     9import finki.paw5.model.enumerations.PhysicalActivity;
    810
    911public interface AuthService {
    1012    User login (String email, String password);
    11 //    Adopter registerAdopter(String password, String repeatPassword, String name, String email, String telephone);
    12 //    Employee registerEmployee(String password, String repeatPassword, String name, String email, String telephone);
     13    Adopter registerAdopter(String name, String email, String password, String telephone, FreeTime freeTime, Funds funds, boolean hasOtherPets, boolean hasKids, Housing housing, PhysicalActivity physicalActivity, boolean willFoster);
     14    Employee registerEmployee(String name, String email, String password, String telephone, String position, Integer shelterId);
    1315
    1416}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/ShelterService.java

    ra762b3a r59a8941  
    33import finki.paw5.model.entities.Shelter;
    44
     5import java.util.List;
    56import java.util.Optional;
    67
    78public interface ShelterService {
    89    Optional<Shelter> findById(Integer id);
     10    List<Shelter> listShelters();
    911}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/AuthServiceImpl.java

    ra762b3a r59a8941  
    11package finki.paw5.service.implementation;
    22
     3import finki.paw5.model.entities.Adopter;
     4import finki.paw5.model.entities.Employee;
    35import finki.paw5.model.entities.User;
    4 import finki.paw5.model.exceptions.NonExistingArgumentsException;
     6import finki.paw5.model.enumerations.FreeTime;
     7import finki.paw5.model.enumerations.Funds;
     8import finki.paw5.model.enumerations.Housing;
     9import finki.paw5.model.enumerations.PhysicalActivity;
     10import finki.paw5.repository.AdopterRepository;
     11import finki.paw5.repository.EmployeeRepository;
    512import finki.paw5.repository.UserRepository;
    613import finki.paw5.service.AuthService;
     
    815
    916import java.time.LocalDate;
    10 import java.util.Objects;
    11 import java.util.Optional;
    1217
    1318@Service
     
    1520
    1621    private final UserRepository userRepository;
     22    private final AdopterRepository adopterRepository;
     23    private final EmployeeRepository employeeRepository;
    1724
    18     public AuthServiceImpl(UserRepository userRepository) {
     25    public AuthServiceImpl(UserRepository userRepository, AdopterRepository adopterRepository, EmployeeRepository employeeRepository) {
    1926        this.userRepository = userRepository;
     27        this.adopterRepository = adopterRepository;
     28        this.employeeRepository = employeeRepository;
    2029    }
    2130
     
    2938    }
    3039
    31     /*
     40
    3241    @Override
    33     public Adopter registerAdopter(String password, String repeatPassword, String name, String email, String telephone) {
    34         if (email == null || email.isEmpty() || password == null || password.isEmpty()) {
    35             //throw new Exception();
    36         }
    37         if (!password.equals(repeatPassword)) {
    38             //throw new Exception();
    39         }
    40         if (this.userRepository.findByEmail(email)!=null) {
    41             //throw new Exception("Username exists:"+email);
    42         }
    43         User user = new User(LocalDate.now(), name, email, password, telephone);
    44         return userRepository.save(user);
     42    public Adopter registerAdopter(String name, String email, String password, String telephone, FreeTime freeTime, Funds funds, boolean hasOtherPets, boolean hasKids, Housing housing, PhysicalActivity physicalActivity, boolean willFoster) {
     43        Adopter adopter = new Adopter(LocalDate.now(), name, email, password, telephone,freeTime,funds,hasOtherPets,hasKids,housing,physicalActivity,willFoster,false);
     44        return adopterRepository.save(adopter);
    4545    }
    46     */
     46
     47    @Override
     48    public Employee registerEmployee(String name, String email, String password, String telephone, String position, Integer shelterId) {
     49        Employee employee = new Employee(LocalDate.now(),name, email,password,telephone,position,shelterId,false);
     50        return employeeRepository.save(employee);
     51    }
     52
    4753}
  • Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/ShelterServiceImplementation.java

    ra762b3a r59a8941  
    66import org.springframework.stereotype.Service;
    77
     8import java.util.List;
    89import java.util.Optional;
    910
     
    2122        return this.shelterRepository.findById(id);
    2223    }
     24
     25    @Override
     26    public List<Shelter> listShelters() {
     27        return shelterRepository.findAll();
     28    }
     29
     30
    2331}
  • Prototype Application/Paw5/src/main/resources/templates/login.html

    ra762b3a r59a8941  
    5353<style>
    5454  body{
    55     color: darkslategray;
     55    color: #212121;
    5656  }
    5757  form{
    58     background-color: bisque;
     58    background-color: lightgray;
    5959    text-align: center;
    6060    padding: 20px;
    6161    border-radius: 20px;
    6262    width: 60%;
     63    margin-left: 300px;
    6364  }
    6465  body{
     
    6667  }
    6768  #button{
    68     background-color: cadetblue;
     69    background-color: #212121;
    6970    color: azure;
    7071    border: none;
  • Prototype Application/Paw5/src/main/resources/templates/register.html

    ra762b3a r59a8941  
    22<html lang="en" xmlns:th="http://www.thymeleaf.org">
    33<head>
    4   <meta charset="UTF-8">
    5   <title>Title</title>
    6   <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    7   <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    8   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    9   <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
     4    <meta charset="UTF-8">
     5    <title>Title</title>
     6    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
     7          integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
     8    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
     9            integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
     10            crossorigin="anonymous"></script>
     11    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
     12            integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
     13            crossorigin="anonymous"></script>
     14    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
     15            integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
     16            crossorigin="anonymous"></script>
    1017
    1118</head>
    1219<body>
    1320<header>
    14   <nav class="navbar navbar-expand-md navbar-dark bg-dark">
    15     <div class="container">
    16       <a class="navbar-brand" href="/home">Paw 5</a>
    17       <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault"
    18               aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
    19         <span class="navbar-toggler-icon"></span>
    20       </button>
     21    <nav class="navbar navbar-expand-md navbar-dark bg-dark">
     22        <div class="container">
     23            <a class="navbar-brand" href="/home">Paw 5</a>
     24            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault"
     25                    aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
     26                <span class="navbar-toggler-icon"></span>
     27            </button>
    2128
    22       <div class="collapse navbar-collapse justify-content-end" id="navbarsExampleDefault">
    23         <ul class="navbar-nav m-auto">
    24           <li class="nav-item m-auto">
    25             <a class="nav-link active" href="/home/aboutUs">About us</a>
    26           </li>
    27           <li class="nav-item m-auto">
    28             <a class="nav-link active" href="/login">Login</a>
    29           </li>
    30           <li class="nav-item m-auto">
    31             <a class="nav-link active" href="/register">Register</a>
    32           </li>
    33         </ul>
    34       </div>
    35     </div>
    36   </nav>
     29            <div class="collapse navbar-collapse justify-content-end" id="navbarsExampleDefault">
     30                <ul class="navbar-nav m-auto">
     31                    <li class="nav-item m-auto">
     32                        <a class="nav-link active" href="/home/aboutUs">About us</a>
     33                    </li>
     34                    <li class="nav-item m-auto">
     35                        <a class="nav-link active" href="/login">Login</a>
     36                    </li>
     37                    <li class="nav-item m-auto">
     38                        <a class="nav-link active" href="/register">Register</a>
     39                    </li>
     40                </ul>
     41            </div>
     42        </div>
     43    </nav>
    3744</header>
    38 <h3>You can take one or more roles on our site.</h3>
    39 <p>You want to adopt or foster a pet? - You are an adopter <br>
    40   You want your pet to be adopted by another person? - You are a surendee <br>
    41   You want to donate to an organisation protection animal rights? - You are a donor<br>
    42   You work in one of our partner's shelters? - You are an employee <br>
    43 </p>
    44 <div>
    45   <form method="post" action="/register"> <!--vaka e na aud-->
     45<div id="middle">
    4646    <h1>Register</h1>
    47     <label for="name">Name and surname:</label>
    48     <input type="text" id="name" name="name"><br><br>
     47    <div>
     48        <form method="post" action="/register"> <!--vaka e na aud-->
     49            <label for="name">Name and surname:</label>
     50            <input type="text" id="name" name="name"><br><br>
    4951
    50     <label for="email">Email:</label>
    51     <input type="email" id="email" name="email"><br><br>
     52            <label for="email">Email:</label>
     53            <input type="email" id="email" name="email"><br><br>
    5254
    53     <label for="password">Password:</label>
    54     <input type="password" id="password" name="password"><br><br>
     55            <label for="password">Password:</label>
     56            <input type="password" id="password" name="password"><br><br>
    5557
    56     <label for="repeatPassword">Repeat password:</label>
    57     <input type="password" id="repeatPassword" name="repeatPassword"><br><br>
     58            <label for="repeatPassword">Repeat password:</label>
     59            <input type="password" id="repeatPassword" name="repeatPassword"><br><br>
    5860
    59     <label for="telephone">Telephone number:</label>
    60     <input type="text" id="telephone" name="telephone"><br><br>
     61            <label for="telephone">Telephone number:</label>
     62            <input type="text" id="telephone" name="telephone"><br><br>
     63
     64          <hr><br><br>
    6165
    6266
    63     <!-- Employee -->
    64     <label for="employee">Register as employee in a shelter</label>
    65     <input type="checkbox" id="employee" name="employee" value="yes"><br><br>
     67            <!-- Employee -->
     68            <label class="role">Register as employee in a shelter</label>
     69            <input type="radio" name="role" value="employee"><br><br>
    6670
    67     <label for="shelter">From which organisation are you coming from?</label>
    68     <select id="shelter" name="shelter" class="form-control">
     71            <label for="shelter">For which shelter do you work for?</label>
     72            <select id="shelter" name="shelter">
    6973
    70       <option
    71               th:each="sh : ${shelters}"
    72               th:value="${sh.getId()}"
    73               th:text="${sh.getName()}">
    74       </option>
     74                <option
     75                        th:each="sh : ${shelters}"
     76                        th:value="${sh.getId()}"
     77                        th:text="${sh.getName()}">
     78                </option>
    7579
    76     </select>
     80            </select><br><br>
    7781
    78     <label for="position">Register as employee in a shelter</label>
    79     <input type="text" id="position" name="position" value="yes"><br><br>
     82            <label for="position">Position:</label>
     83            <input type="text" id="position" name="position"><br><br>
     84
     85          <hr><br><br>
    8086
    8187
    82     <!-- Adopter -->
    83     <label for="adopter">Register as adopter</label>
    84     <input type="checkbox" id="adopter" name="adopter" value="yes"><br><br>
     88            <!-- Adopter -->
     89            <label class="role">Register as an adopter</label>
     90            <input type="radio" name="role" value="adopter"><br><br>
    8591
    86     <label for="freeTime">Free time:</label>
    87     <select id="freeTime" name="freeTime">
    88       <option value="LOW">low</option>
    89       <option value="MEDIUM">medium</option>
    90       <option value="HIGH">high</option>
    91     </select><br><br>
     92            <p>
     93                *the following information is needed so we can provide our best services for you*
     94            </p>
    9295
    93     <label for="funds">Finances:</label>
    94     <select id="funds" name="funds">
    95       <option value="LOW">low</option>
    96       <option value="MEDIUM">medium</option>
    97       <option value="HIGH">high</option>
    98     </select><br><br>
     96            <label for="freeTime">Free time:</label>
     97            <select id="freeTime" name="freeTime">
     98                <option value="LOW">low</option>
     99                <option value="MEDIUM">medium</option>
     100                <option value="HIGH">high</option>
     101            </select><br><br>
    99102
    100     <label for="hasOtherPets">You keep other pets</label>
    101     <input type="checkbox" id="hasOtherPets" name="hasOtherPets" value="yes"> Yes <br><br>
     103            <label for="funds">Finances:</label>
     104            <select id="funds" name="funds">
     105                <option value="LOW">low</option>
     106                <option value="MEDIUM">medium</option>
     107                <option value="HIGH">high</option>
     108            </select><br><br>
    102109
    103     <label for="hasKids">The adopted pet will have interaction with kids</label>
    104     <input type="checkbox" id="hasKids" name="hasKids" value="yes"><br><br>
     110            <label>Do you keep other pets?</label>
     111            <input type="radio" class="hasPets" name="hasOtherPets" value=true> Yes
     112            <input type="radio" class="hasPets" name="hasOtherPets" value=false> No <br><br>
    105113
    106     <label for="housing">Housing:</label>
    107     <select id="housing" name="housing">
    108       <option value="APARTMENT">apartment</option>
    109       <option value="HOUSE">house</option>
    110     </select><br><br>
     114            <label>Will the adopted pet have interaction with kids?</label>
     115            <input type="radio" name="hasKids" value=true>Yes
     116            <input type="radio" name="hasKids" value=false>No<br><br>
    111117
    112     <label for="physicalActivity">Physical activity:</label>
    113     <select id="physicalActivity" name="physicalActivity">
    114       <option value="LOW">low</option>
    115       <option value="MEDIUM">medium</option>
    116       <option value="HIGH">high</option>
    117     </select><br><br>
     118            <label for="housing">Housing:</label>
     119            <select id="housing" name="housing">
     120                <option value="APARTMENT">apartment</option>
     121                <option value="HOUSE">house</option>
     122            </select><br><br>
    118123
    119     <label for="willFoster">The adopted pet will have interaction with kids</label>
    120     <input type="checkbox" id="willFoster" name="willFoster" value="yes"><br><br>
     124            <label for="physicalActivity">Physical activity:</label>
     125            <select id="physicalActivity" name="physicalActivity">
     126                <option value="LOW">low</option>
     127                <option value="MEDIUM">medium</option>
     128                <option value="HIGH">high</option>
     129            </select><br><br>
    121130
    122     <!-- Donor -->
    123     <label for="donor">Register as donor</label>
    124     <input type="checkbox" id="donor" name="donor" value="yes"><br><br>
     131            <label>Are you willing to foster?</label>
     132            <input type="radio" name="willFoster" value=true>Yes
     133            <input type="radio" name="willFoster" value=false>No<br><br>
    125134
    126     <label for="organisation">From which organisation are you coming from?</label>
    127     <select id="organisation" name="organisation">
    128       <option value="EVN">EVN</option>
    129     </select><br><br>
     135          <hr><br>
    130136
    131     <!-- Surendee -->
    132     <label for="surendee">Register as surendee</label>
    133     <input type="checkbox" id="surendee" name="surendee" value="yes"><br><br>
     137            <!-- Donor -->
     138            <label class="role">Register as donor</label>
     139            <input type="radio" name="role" value="donor"><br><br>
    134140
    135     <input id="button" type="submit" value="Submit">
    136   </form>
     141            <label for="organisation">From which organisation are you coming from?</label>
     142            <select id="organisation" name="organisation">
     143                <option
     144                        th:each="sh : ${organisations}"
     145                        th:value="${sh.getId()}"
     146                        th:text="${sh.getName()}">
     147                </option>
     148            </select><br><br>
     149
     150          <hr><br>
     151
     152            <!-- Surendee -->
     153            <label class="role">Register as surendee</label>
     154            <input type="radio" name="role" value="surendee"><br><br>
     155
     156            <input id="button" type="submit" value="Submit">
     157        </form>
     158    </div>
     159  <p>You want to adopt or foster a pet? - You are an adopter <br>
     160    You want your pet to be adopted by another person? - You are a surendee <br>
     161    You want to donate to an organisation protection animal rights? - You are a donor<br>
     162    You work in one of our partner's shelters? - You are an employee <br>
     163  </p>
    137164</div>
    138165</body>
    139166<style>
    140   body{
    141     color: darkslategray;
    142   }
    143   form{
    144     background-color: bisque;
    145     text-align: center;
    146     padding: 20px;
    147     border-radius: 20px;
    148     width: 60%;
    149   }
    150   body{
    151     font-family: Montserrat,serif;
    152   }
    153   #button{
    154     background-color: cadetblue;
    155     color: azure;
    156     border: none;
    157     height: 40px;
    158     width: 80px;
    159     border-radius: 20px;
    160   }
     167    body {
     168        color: #212121;
     169    }
     170
     171    form {
     172        background-color: lightgray;
     173        text-align: center;
     174        padding: 20px;
     175        border-radius: 20px;
     176        width: 60%;
     177        margin-left: 300px;
     178    }
     179
     180    body {
     181        font-family: Montserrat, serif;
     182    }
     183
     184    #button {
     185        background-color: #212121;
     186        color: azure;
     187        border: none;
     188        height: 40px;
     189        width: 80px;
     190        border-radius: 20px;
     191    }
     192    #middle{
     193      text-align: center;
     194    }
     195    .role{
     196      color:darkred;
     197    }
    161198</style>
    162199</html>
Note: See TracChangeset for help on using the changeset viewer.