Skip to content
Snippets Groups Projects
Commit 077b2f45 authored by Harrison Davies's avatar Harrison Davies
Browse files

Merge branch '218-create-a-new-event-so-that-i-can-add-a-new-event-to-this' into 'release/Sprint-4'

Resolve "As an admin user, I want to be able to create a new event so that I can add a new event to this platform and advertise it to the community."

See merge request c24108486/team-11-polish-community-group!52
parents 1afc3b97 e2ef9341
No related branches found
No related tags found
No related merge requests found
Showing
with 707 additions and 130 deletions
......@@ -59,7 +59,6 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.mockito:mockito-core:4.0.0' // Mocking library
testImplementation 'org.mockito:mockito-junit-jupiter:4.0.0' // JUnit 5 support for Mockito
......
package polish_community_group_11.polish_community.event.controllers;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import polish_community_group_11.polish_community.event.services.EventRepository;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import polish_community_group_11.polish_community.event.models.viewmodel.EventForm;
import org.springframework.web.bind.annotation.*;
import polish_community_group_11.polish_community.event.models.Event;
import polish_community_group_11.polish_community.event.models.EventImpl;
import polish_community_group_11.polish_community.event.services.EventService;
import polish_community_group_11.polish_community.register.services.UserService;
import java.security.Principal;
import java.sql.SQLException;
@Controller
public class EventController {
// Inject the EventRepository service to handle event-related data operations
private EventRepository eventService;
private EventService eventService;
private UserService userService;
@Autowired
// Constructor-based dependency injection for EventRepository
public EventController(EventRepository eventService){
public EventController(EventService eventService, UserService userService) {
this.eventService = eventService;
this.userService = userService;
}
// Controller method to handle GET requests for the "/event" URL
......@@ -50,4 +67,65 @@ public class EventController {
// Return the populated ModelAndView object, which will render the event details view
return modelAndView;
}
//Controller Method to load create new event page
@GetMapping("event/add")
public ModelAndView addEvent() {
ModelAndView modelAndView = new ModelAndView("event/add-event");
//Passing Form object for validation
modelAndView.addObject("event", new EventForm());
/* Form action string to check the type of action to perform and dynamically
use the same form for both create and update */
modelAndView.addObject("formAction", "/event/add");
return modelAndView;
}
@PostMapping("event/add")
public ModelAndView addEvent(@Valid @ModelAttribute("event") EventForm event,
BindingResult bindingResult, Model model,
Principal principal, RedirectAttributes redirectAttributes) throws SQLException {
ModelAndView modelAndView = new ModelAndView("event/add-event");
if(bindingResult.hasErrors()) {
modelAndView.addObject(model.asMap());
/* Form action string to check the type of action to perform and dynamically
use the same form for both create and update */
modelAndView.addObject("formAction", "/event/add");
}
else{
if(event==null){
throw new NullPointerException("New event is empty or null");
}
eventService.addNewEvent(event.processEventForm(),principal.getName());
redirectAttributes.addFlashAttribute("successMessage", "Event created successfully!");
modelAndView.setViewName("redirect:/event");
}
return modelAndView;
}
//Update Events
@GetMapping("event/edit/{id}")
public ModelAndView editEvent(@PathVariable int id) {
EventForm event = eventService.getEventById(id).processEventToEventForm();
ModelAndView modelAndView = new ModelAndView("event/add-event");
modelAndView.addObject("event", event);
modelAndView.addObject("formAction", "/event/edit");
return modelAndView;
}
@PostMapping("/event/edit")
public ModelAndView editEvent(@Valid @ModelAttribute("event") EventForm event,
BindingResult bindingResult, Model model) throws SQLException {
ModelAndView modelAndView = new ModelAndView("event/add-event");
if (bindingResult.hasErrors()) {
modelAndView.addObject(model.asMap());
modelAndView.addObject("formAction", "/event/edit");
} else {
eventService.getEditEvent(event.processEventForm());
modelAndView.setViewName("redirect:/event");
}
return modelAndView;
}
}
package polish_community_group_11.polish_community.event.services;
package polish_community_group_11.polish_community.event.dao;
import polish_community_group_11.polish_community.event.models.Event;
import java.sql.SQLException;
import java.util.List;
public interface EventRepository {
......@@ -8,4 +10,6 @@ public interface EventRepository {
List<Event> getAllEvents();
Event getEventById(int id);
void addNewEvent(Event newEvent) throws SQLException;
Event editEvent(Event event)throws SQLException;
}
package polish_community_group_11.polish_community.event.services;
package polish_community_group_11.polish_community.event.dao;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import polish_community_group_11.polish_community.event.models.Event;
import polish_community_group_11.polish_community.event.models.EventImpl;
import java.sql.SQLException;
import java.util.List;
@Repository // Marks this class as a Spring Data repository for database interaction
public class EventRepositoryImpl implements EventRepository {
// JdbcTemplate instance for executing SQL queries
private JdbcTemplate jdbc;
private final JdbcTemplate jdbc;
// RowMapper to map SQL result set rows to Event objects
private RowMapper<Event> eventItemMapper;
......@@ -74,4 +77,64 @@ public class EventRepositoryImpl implements EventRepository {
return event;
}
public void addNewEvent(Event newEvent) throws SQLException, NullPointerException{
if(newEvent==null){
throw new NullPointerException("Event cannot be null");
}
String dbInsertSql =
"insert into event " +
"(event_title, event_description, location, " +
"event_date, event_time,user_id, event_poster_url,whyJoin,benefits)" +
" values (?,?,?,?,?,?,?,?,?)";
try{
jdbc.update(dbInsertSql,
newEvent.getEvent_title(),
newEvent.getDescription(),
newEvent.getDescription(),
newEvent.getEvent_date(),
newEvent.getEvent_time(),
newEvent.getUser_id(),
newEvent.getImageUrl(),
newEvent.getWhyJoin(),
newEvent.getBenefits()
);
}
catch (DataAccessException e) {
throw new SQLException("Failed to insert new information record", e);
}
}
// Updates selected record with new updated information
public Event editEvent(Event event)throws SQLException {
String updateSql = "UPDATE event " +
"SET event_title = ?, event_description = ?, " +
"event_date = ?, event_time = ?, " +
"location = ?, user_id = ?, event_poster_url = ?, " +
"whyJoin = ?, benefits = ? " +
"WHERE event_id = ?";
try {
// jdbc.update() is a method that will execute the sql query
// replaces the ? with the actual values from the news object
int rowsAffected = jdbc.update(updateSql,
event.getEvent_title(),
event.getDescription(),
event.getEvent_date(),
event.getEvent_time(),
event.getLocation(),
event.getUser_id(),
event.getImageUrl(),
event.getWhyJoin(),
event.getBenefits(),
event.getEvent_id()
);
// error handling
if (rowsAffected == 0) {
throw new SQLException("No event item was updated. Check the ID provided.");
}
} catch (DataAccessException e) {
throw new SQLException("Error updating event with ID: " + event.getEvent_id(), e);
}
return event;
}
}
package polish_community_group_11.polish_community.event.models;
import polish_community_group_11.polish_community.event.models.viewmodel.EventForm;
import java.time.LocalDate;
import java.time.LocalTime;
......@@ -27,4 +29,5 @@ public interface Event {
public String getBenefits();
public void setBenefits(String benefits);
EventForm processEventToEventForm();
}
package polish_community_group_11.polish_community.event.models;
import jakarta.validation.constraints.FutureOrPresent;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
import polish_community_group_11.polish_community.event.models.viewmodel.EventForm;
import java.time.LocalDate;
import java.time.LocalTime;
......@@ -20,4 +26,12 @@ public class EventImpl implements Event{
private String whyJoin;
private String benefits;
public EventForm processEventToEventForm(){
EventForm eventForm = new EventForm(
event_id, event_title, description, event_date, event_time,
location, user_id, imageUrl, whyJoin, benefits
);
return eventForm;
}
}
package polish_community_group_11.polish_community.event.models.viewmodel;
import jakarta.validation.constraints.FutureOrPresent;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.URL;
import polish_community_group_11.polish_community.event.models.Event;
import polish_community_group_11.polish_community.event.models.EventImpl;
import java.time.LocalDate;
import java.time.LocalTime;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class EventForm {
private int event_id;
@NotEmpty(message = "Please enter the event title")
private String event_title;
@NotEmpty(message = "Please enter the event description")
private String description;
@FutureOrPresent(message = "The date cannot be in the past")
@NotNull(message = "Please enter the event date")
private LocalDate event_date;
@NotNull(message = "Please enter the time of the event")
private LocalTime event_time;
@NotEmpty(message = "Please provide the location of event")
private String location;
private int user_id;
@NotEmpty(message = "Please provide event image url")
@Pattern(regexp = ".*\\.(png|jpg|jpeg|gif).*", message = "Must be a valid image (png, jpg, jpeg, gif).")
@URL(message = "Not a valid image url")
private String imageUrl;
private String whyJoin;
private String benefits;
public Event processEventForm(){
if (event_title == null || event_title.isEmpty()) {
throw new IllegalArgumentException("Event title is required");
}
if (event_date == null) {
throw new IllegalArgumentException("Event date is required");
}
if (event_time == null) {
throw new IllegalArgumentException("Event time is required");
}
if (location == null || location.isEmpty()) {
throw new IllegalArgumentException("Location is required");
}
Event event = new EventImpl(
event_id, event_title, description, event_date, event_time,
location, user_id, imageUrl, whyJoin, benefits
);
return event;
}
}
package polish_community_group_11.polish_community.event.services;
import polish_community_group_11.polish_community.event.models.Event;
import java.sql.SQLException;
import java.util.List;
public interface EventService {
List<Event> getAllEvents();
Event getEventById(int id);
void addNewEvent(Event newEvent, String email) throws SQLException;
Event getEditEvent(Event event) throws SQLException;
}
\ No newline at end of file
package polish_community_group_11.polish_community.event.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import polish_community_group_11.polish_community.event.dao.EventRepository;
import polish_community_group_11.polish_community.event.models.Event;
import polish_community_group_11.polish_community.register.services.UserService;
import java.sql.SQLException;
import java.util.List;
@Service
public class EventServiceImpl implements EventService {
private final EventRepository eventRepository;
private final UserService userService;
@Autowired
public EventServiceImpl(EventRepository eventRepository, UserService userService) {
this.eventRepository = eventRepository;
this.userService=userService;
}
public List<Event> getAllEvents(){
return eventRepository.getAllEvents();
}
public Event getEventById(int id){
return eventRepository.getEventById(id);
}
public void addNewEvent(Event newEvent, String email) throws SQLException {
newEvent.setUser_id(userService.findUserIdByEmail(email));
eventRepository.addNewEvent(newEvent);
}
public Event getEditEvent(Event event) throws SQLException {
return eventRepository.editEvent(event);
}
}
......@@ -8,9 +8,11 @@ public interface UserRepository {
int saveUser(User user); // add user into the database
User findByEmail(String email); // find user by email
int findUserIdByEmail(String email);
User findById(int id); // find user by ID
List<User> findAllUsers(); // get all the users
String findUserFullNameByEmail(String email);
}
\ No newline at end of file
......@@ -85,6 +85,22 @@ public class UserRepositoryImpl implements UserRepository {
}
}
public int findUserIdByEmail(String email) {
if(email.trim().equals("")|| email == null){
throw new IllegalArgumentException("Email is null or empty");
}
User user = findByEmail(email);
if(user == null){
throw new NullPointerException("User not found");
}
return user.getId();
}
public String findUserFullNameByEmail(String email) {
User user = findByEmail(email);
return user.getFullname();
}
// function for finding user by id
public User findById(int id) {
......
......@@ -10,6 +10,8 @@ public interface UserService {
User findById(int id);
User findByEmail(String email);
int findUserIdByEmail(String email);
List<User> findAllUsers();
public String findUserFullNameByEmail(String email);
}
\ No newline at end of file
......@@ -37,4 +37,10 @@ public class UserServiceImpl implements UserService {
// Calls findAll method of the UserRepository
return userRepository.findAllUsers();
}
public int findUserIdByEmail(String email){
return userRepository.findUserIdByEmail(email);
}
public String findUserFullNameByEmail(String email){
return userRepository.findUserFullNameByEmail(email);
}
}
......@@ -33,8 +33,6 @@ public class WebSecurityConfig {
private final RoleService roleService;
private final String[] whiteListingPath = {
// "/event",
// "event/*"
"/api/feed/**"
};
......
......@@ -15,26 +15,6 @@ VALUES
delete from event;
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url,whyJoin,benefits)
values ('Science Fair', 'Students explore through the science fair', 'Cardiff', current_date,current_time, 1, 'https://marketplace.canva.com/EAE53TNAVD8/1/0/1131w/canva-event-present-science-fair-promotion-poster-1abqT-GiCNQ.jpg','Participating in the Science Fair offers you a unique opportunity to dive deep into the world of science, innovation, and discovery. Whether you''re a student eager to showcase your scientific knowledge or an individual with a passion for learning, this event is the perfect platform to fuel your curiosity. Here’s why you should join:
Engage with Innovative Ideas: Explore cutting-edge scientific projects that challenge the status quo and inspire new ways of thinking.
Collaborate with Like-Minded Individuals: Meet fellow science enthusiasts, students, and professionals who share your interests and passion for discovery.
Boost Your Critical Thinking: Through the process of research, experimentation, and presentation, you’ll develop critical problem-solving skills that are invaluable in any field.
Expand Your Knowledge: Learn about new technologies, scientific theories, and groundbreaking advancements that will shape the future of science and innovation.
Be a Part of a Larger Community: Join a global community of science advocates and future scientists, making valuable connections that could open doors to future opportunities.', 'Hands-On Experience: Gain practical, hands-on experience in the scientific method, from research and hypothesis testing to data analysis and presentation.
Develop Presentation Skills: Sharpen your ability to communicate complex scientific concepts in an engaging and accessible way, an essential skill for any future career.
Exposure to Career Opportunities: Connect with professionals in science, education, and industry, opening up potential career pathways, internships, and scholarships.
Recognition and Prizes: Stand a chance to win awards and gain recognition for your hard work and creativity. Whether you’re awarded for your innovation, research, or presentation, your efforts will be acknowledged.
Confidence Building: Presenting your work to peers, teachers, and judges builds confidence in your abilities and boosts self-esteem, allowing you to grow as both a scientist and an individual.
Inspire Future Projects: Your participation could spark new ideas and motivate others to start their own scientific endeavors, contributing to a culture of curiosity and learning.
Stay Ahead of the Curve: By participating, you gain knowledge about the latest trends in science and technology, giving you an edge in academic and professional fields.
By joining this science fair, you are not only enriching your own learning experience but also contributing to a vibrant community of innovators and explorers.');
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url,whyJoin,benefits)
values ('Games Fair', 'Gamers explore through the game fair', 'Bristol', current_date,current_time, 1, 'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/game-event-poster-template-c54aaeed440befaacf79e6dd35deb8f5_screen.jpg?ts=1486132851','Abc', 'Def');
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url,whyJoin,benefits)
values ('Bikes Fair', 'Riders explore through the Ride fair', 'Newport', current_date,current_time, 1, 'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/bike-fest-poster-design-template-fb1cc1ab4b2aee783f8ee75476c4c92d_screen.jpg?ts=1637012682','Abc', 'Def');
-- mock data for news
delete from news;
INSERT INTO news (news_title, news_summary, news_source, news_link, news_image_url, user_id, news_upload_date)
......@@ -74,16 +54,6 @@ VALUES
5, current_date);
-- mock data for events
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url)
values ('Bikes Fair', 'Riders explore through the Ride fair', 'Newport', current_date,current_time, 1, 'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/bike-fest-poster-design-template-fb1cc1ab4b2aee783f8ee75476c4c92d_screen.jpg?ts=1637012682');
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url)
values ('Bikes Fair', 'Riders explore through the Ride fair', 'Newport', current_date,current_time, 1, 'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/bike-fest-poster-design-template-fb1cc1ab4b2aee783f8ee75476c4c92d_screen.jpg?ts=1637012682');
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url)
values ('Bikes Fair', 'Riders explore through the Ride fair', 'Newport', current_date,current_time, 1, 'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/bike-fest-poster-design-template-fb1cc1ab4b2aee783f8ee75476c4c92d_screen.jpg?ts=1637012682');
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url)
values ('Bikes Fair', 'Riders explore through the Ride fair', 'Newport', current_date,current_time, 1, 'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/bike-fest-poster-design-template-fb1cc1ab4b2aee783f8ee75476c4c92d_screen.jpg?ts=');
-- insert standard roles into roles table
INSERT INTO roles (role_name) VALUES ('ADMIN');
......@@ -139,3 +109,29 @@ INSERT INTO post_likes (post_id, user_id) VALUES
(2, 2),
(2, 4);
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url,whyJoin,benefits)
values ('Science Fair', 'Students explore through the science fair', 'Cardiff', current_date,current_time, 1, 'https://marketplace.canva.com/EAE53TNAVD8/1/0/1131w/canva-event-present-science-fair-promotion-poster-1abqT-GiCNQ.jpg','Participating in the Science Fair offers you a unique opportunity to dive deep into the world of science, innovation, and discovery. Whether you''re a student eager to showcase your scientific knowledge or an individual with a passion for learning, this event is the perfect platform to fuel your curiosity. Here’s why you should join:
Engage with Innovative Ideas: Explore cutting-edge scientific projects that challenge the status quo and inspire new ways of thinking.
Collaborate with Like-Minded Individuals: Meet fellow science enthusiasts, students, and professionals who share your interests and passion for discovery.
Boost Your Critical Thinking: Through the process of research, experimentation, and presentation, you’ll develop critical problem-solving skills that are invaluable in any field.
Expand Your Knowledge: Learn about new technologies, scientific theories, and groundbreaking advancements that will shape the future of science and innovation.
Be a Part of a Larger Community: Join a global community of science advocates and future scientists, making valuable connections that could open doors to future opportunities.', 'Hands-On Experience: Gain practical, hands-on experience in the scientific method, from research and hypothesis testing to data analysis and presentation.
Develop Presentation Skills: Sharpen your ability to communicate complex scientific concepts in an engaging and accessible way, an essential skill for any future career.
Exposure to Career Opportunities: Connect with professionals in science, education, and industry, opening up potential career pathways, internships, and scholarships.
Recognition and Prizes: Stand a chance to win awards and gain recognition for your hard work and creativity. Whether you’re awarded for your innovation, research, or presentation, your efforts will be acknowledged.
Confidence Building: Presenting your work to peers, teachers, and judges builds confidence in your abilities and boosts self-esteem, allowing you to grow as both a scientist and an individual.
Inspire Future Projects: Your participation could spark new ideas and motivate others to start their own scientific endeavors, contributing to a culture of curiosity and learning.
Stay Ahead of the Curve: By participating, you gain knowledge about the latest trends in science and technology, giving you an edge in academic and professional fields.
By joining this science fair, you are not only enriching your own learning experience but also contributing to a vibrant community of innovators and explorers.');
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url,whyJoin,benefits)
values ('Games Fair', 'Gamers explore through the game fair', 'Bristol', current_date,current_time, 1, 'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/game-event-poster-template-c54aaeed440befaacf79e6dd35deb8f5_screen.jpg?ts=1486132851','Abc', 'Def');
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url,whyJoin,benefits)
values ('Bikes Fair', 'Riders explore through the Ride fair', 'Newport', current_date,current_time, 1, 'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/bike-fest-poster-design-template-fb1cc1ab4b2aee783f8ee75476c4c92d_screen.jpg?ts=1637012682','Abc', 'Def');
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url)
values ('Bikes Fair', 'Riders explore through the Ride fair', 'Newport', current_date,current_time, 1, 'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/bike-fest-poster-design-template-fb1cc1ab4b2aee783f8ee75476c4c92d_screen.jpg?ts=1637012682');
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url)
values ('Bikes Fair', 'Riders explore through the Ride fair', 'Newport', current_date,current_time, 1, 'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/bike-fest-poster-design-template-fb1cc1ab4b2aee783f8ee75476c4c92d_screen.jpg?ts=1637012682');
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url)
values ('Bikes Fair', 'Riders explore through the Ride fair', 'Newport', current_date,current_time, 1, 'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/bike-fest-poster-design-template-fb1cc1ab4b2aee783f8ee75476c4c92d_screen.jpg?ts=1637012682');
insert into event (event_title, event_description, location, event_date, event_time,user_id, event_poster_url)
values ('Bikes Fair', 'Riders explore through the Ride fair', 'Newport', current_date,current_time, 1, 'https://d1csarkz8obe9u.cloudfront.net/posterpreviews/bike-fest-poster-design-template-fb1cc1ab4b2aee783f8ee75476c4c92d_screen.jpg?ts=');
......@@ -39,22 +39,6 @@ create table if not exists information
) engine = InnoDB;
-- create schema for event
create table if not exists event(
event_id int primary key auto_increment,
event_title varchar(255),
event_description varchar(255),
location varchar(255),
event_date date,
event_time time,
user_id int,
event_poster_url varchar(255),
whyJoin text,
benefits text
)engine = InnoDB;
-- schema for news
create table if not exists news
......@@ -145,3 +129,19 @@ CREATE TABLE IF NOT EXISTS comment
FOREIGN KEY (post_id) REFERENCES feed(post_id),
FOREIGN KEY (user_id) REFERENCES users (id)
) ENGINE = InnoDB;
-- create schema for event
create table if not exists event(
event_id int primary key auto_increment,
event_title varchar(255),
event_description varchar(255),
location varchar(255),
event_date date,
event_time time,
user_id int,
event_poster_url varchar(255),
whyJoin text,
benefits text,
foreign key event_user_id_fk (user_id) references users(id)
) engine = InnoDB;
\ No newline at end of file
section {
font-family: Arial, sans-serif;
padding: 20px;
}
h1 {
font-size: 24px;
margin-bottom: 20px;
}
fieldset {
border: none;
padding: 0;
}
label {
display: block;
margin-bottom: 8px;
margin-top: 10px;
font-weight: bold;
}
input[type="date"], input[type="time"]{
margin-bottom: 10px;
width: 80%;
padding: 10px;
box-sizing: border-box;
border-radius: 4px;
border: 1px solid #ccc;
}
input[type="date"]:focus, input[type="time"]:focus {
/*border-color: 1px solid var(--primary-color);*/
box-shadow: 0 0 5px var(--border-color);
outline: solid var(--border-color);
}
fieldset > input[type="text"], textarea {
width: 95%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
}
input[type="text"]:focus, textarea:focus{
outline: solid var(--border-color);
}
.event-date-and-location-card{
display: flex;
justify-content: space-between;
width: 95%;
}
.event-date-card, .event-time-card{
flex:1;
}
.event-location-card{
flex: 2;
}
.event-location-input{
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
}
textarea {
height: 100px;
}
.buttons {
display: flex;
justify-content: flex-end;
width: 97%;
}
button {
padding: 10px 20px;
margin-left: 10px;
border: none;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
}
.cancel {
background-color: var(--border-color);
color: var(--primary-color);
}
.submit {
background-color: var(--primary-color);
color: var(--alternate-text);
}
button:hover {
opacity: 0.7;
}
a.button {
display: inline-block;
padding: 10px 20px;
margin-left: 10px;
font-size: 16px;
text-align: center;
text-decoration: none;
cursor: pointer;
}
.backButton{
color: black;
text-decoration: none;
}
a.button:hover {
opacity: 0.7;
}
.alert{
color: red;
display: block;
height: auto;
margin: 2px 0 10px;
}
\ No newline at end of file
/* General Styles */
/* Center the form on the screen */
section {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
/*height: 100vh;*/
padding: 0 20px;
}
/* Form styling */
form {
background-color: var(--secondary-color);
border-radius: 10px;
padding: 30px;
width: 100%;
max-width: 600px;
box-sizing: border-box;
margin: auto;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Add some shadow to give the form a floating effect */
}
/* Header */
h1 {
text-align: left;
margin-bottom: 20px;
font-size: 24px;
color: #333;
}
/* Label styling */
label {
display: block;
font-weight: bold;
margin-bottom: 10px;
color: #333;
font-size: 16px;
}
/* Input and Textarea Styling */
input[type="text"], input[type="date"], input[type="time"], input[type="url"], textarea {
width: 100%;
padding: 12px;
margin-bottom: 20px;
border: 1px solid var(--border-color);
border-radius: 5px;
font-size: 16px;
color: #333;
background-color: var(--background-color); /* Light background for inputs */
}
textarea {
resize: vertical;
min-height: 120px;
}
/* Alert message styling for errors */
.alert {
color: var(--secondary-color);
background-color: var(--border-color);
padding: 5px;
border-radius: 5px;
font-size: 14px;
}
.alert-warning {
color: #8a6d3b;
background-color: #fcf8e3;
}
/* Button styling */
.buttons {
display: flex;
justify-content: space-between;
gap: 15px;
}
/* Submit and Cancel button styling */
button.submit {
background-color: #5bc0de;
color: white;
border: none;
padding: 12px 20px;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
button.submit:hover {
background-color: #31b0d5;
}
#cancelButton {
background-color: #f44336;
color: white;
border: none;
padding: 12px 20px;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
text-decoration: none; /* Remove underline */
display: inline-block;
text-align: center;
transition: background-color 0.3s;
}
#cancelButton:hover {
background-color: #e53935;
}
/* Responsive Styles */
@media (max-width: 768px) {
section {
padding: 20px;
}
form {
width: 100%;
max-width: 90%;
padding: 20px;
}
h1 {
font-size: 20px;
}
}
/* Basic reset to ensure consistent styling across browsers */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #E3E2DF;
display: flex;
justify-content: center;
align-items: flex-start;
height: 100vh; /* Full height of the viewport */
margin: 0;
padding-top: 10px;
}
#event-detail-container {
width: 80%;
max-width: 90%;
background-color: #fff;
width: 100%;
background-color: var(--secondary-color);
padding: 30px;
border-radius: 10px;
box-shadow: 0 0 15px 2px #E3AFBC;
margin-top: 2rem;
background-image: linear-gradient(to right, #e3e2df,white);
}
.backButton{
color: var(--text-color);
text-decoration: none;
}
.event-detail-card {
......@@ -34,7 +16,7 @@ body {
.event-detail-card h1 {
font-size: 2rem;
color: #5D001E;
color: var(--text-color);
margin-bottom: 20px;
}
......@@ -48,14 +30,14 @@ body {
.event-image {
width: 80%; /* Resizes the image to 80% of the container */
height: auto;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
border-radius: 10px;
box-shadow: 0 4px 6px var(--border-color);
}
/* Style for event description, date, and location */
p {
font-size: 1rem;
color: #555;
color: var(--secondary-text-color);
line-height: 1.6;
margin-bottom: 15px;
}
......@@ -72,15 +54,15 @@ strong {
.event-benefits {
margin: 20px 0; /* Adds vertical spacing between sections */
padding: 15px; /* Adds padding inside the sections */
background-color: #E3E2DF; /* White background for each section */
border: 1px solid #E3AFBC; /* Light border to separate sections */
background-color: var(--border-color); /* White background for each section */
border: 1px solid var(--primary-color); /* Light border to separate sections */
border-radius: 8px; /* Rounded corners for the section */
}
/* Styling for the headings inside the event-benefits sections */
.event-benefits h2 {
font-size: 24px; /* Sets a larger font size for the headings */
color: #EE4C7C; /* Blue color for the headings */
color: var(--text-color); /* Blue color for the headings */
margin-bottom: 10px; /* Adds space below the heading */
}
......@@ -106,8 +88,8 @@ strong {
.register-button {
background-color: #EE4C7C;
color: white;
background-color: var(--primary-color);
color: var(--secondary-color);
border: none;
padding: 10px 20px;
font-size: 1rem;
......@@ -117,5 +99,6 @@ strong {
}
.register-button:hover {
background-color: #9A1750;
background-color: var(--border-color);
color: var(--text-color);
}
/* General Styles */
body {
section {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #E3E2DF;
/*padding: 20px;*/
}
.general-headings-layout h1{
font-weight: bolder;
font-size:xx-large;
}
.general-headings-layout button{
padding: 10px 15px;
border: none;
font-size: 14px;
cursor: pointer;
border-radius: 5px;
background-color: var(--primary-color);
color: var(--alternate-text);
}
.general-headings-layout button:hover {
background-color: var(--border-color);
color: var(--text-color);
border: 2px solid var(--primary-color);
}
/* Main container for event details */
#event-details {
padding: 20px;
background-color: #E3E2DF;
/*padding: 20px;*/
margin: 0 5% 2% 5%;
background-color: var(--background-color);
}
.general-headings-layout{
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 3%;
}
/* Event grid container for dynamically generated cards */
.event-grid {
display: grid;
......@@ -23,26 +52,24 @@ body {
/* Styling each event card */
.event-card {
background: #fff;
border: 1px solid #ddd;
background: var(--secondary-color);
border: 2px solid var(--border-color);
border-radius: 10px;
overflow: hidden;
/*overflow: hidden;*/
transition: transform 0.3s ease, box-shadow 0.3s ease;
width: 100%;
max-width: 300px; /* Ensures cards do not get too wide */
box-shadow: 0 0 15px 2px #E3AFBC;
min-width: 60%;
max-width: 80%; /* Ensures cards do not get too wide */
box-shadow: 0 0 15px 2px var(--primary-color);
}
/* Hover effect for the card */
.event-card:hover {
transform: translateY(-10px);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
box-shadow: 0 8px 16px var(--border-color);
}
/* Event poster styling */
.event-poster {
position: relative;
overflow: hidden;
height: 200px;
justify-content: center;
align-items: center;
......@@ -51,14 +78,15 @@ body {
.event-poster img {
width: 100%;
height: 100%;
object-fit: cover; /* Ensures the image covers the container */
object-fit: fill;
/* Ensures the image covers the container */
}
/* Title styling */
.event-card h2,
.event-card h3 {
font-size: 1.5em;
color: #5D001E;
color: var(--primary-color);
margin: 10px 0;
text-align: center;
}
......@@ -70,41 +98,52 @@ body {
margin: 10px;
}
/* Remove underline from links with the class 'event-link' */
.event-link {
text-decoration: none; /* Removes the underline */
/* Event buttons container */
.event-card-button {
display: flex;
/*flex-direction: column;*/
align-items: center; /* Center buttons horizontally */
/*gap: 10px; !* Adds space between buttons *!*/
}
/* Register button styling */
.register-button {
display: block;
width: 50%; /* Ensures the button spans the full width of its container */
max-width: 300px; /* You can set a max-width to control the button size */
/* Common button styling for both buttons */
.event-card-button button {
max-width: 250px; /* Controls the button size */
padding: 10px;
margin: 10px auto; /* Horizontally centers the button and adds vertical spacing */
background-color: #EE4C7C;
color: #fff;
background-color: var(--primary-color);
color: var(--secondary-color);
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1em;
transition: background-color 0.3s ease, transform 0.3s ease; /* Add transition effects */
}
.register-button:hover {
background-color: #9A1750;
background-color: var(--border-color);
color: var(--primary-color);
}
/* Responsive adjustments */
/* On medium screens, switch to a 2-column layout */
@media (max-width: 768px) {
.event-grid {
grid-template-columns: repeat(2, 1fr);
/* Hover effect for the buttons */
.event-card-button button:hover {
background-color: var(--border-color);
transform: scale(1.05); /* Slight scaling effect on hover */
}
/* Remove underline from links with the class 'event-link' */
.event-link {
text-decoration: none; /* Removes the underline */
margin:auto;
}
/* On smaller screens, switch to a single column layout */
@media (max-width: 480px) {
.event-grid {
grid-template-columns: 1fr; /* Single column for very small screens */
.event-link button {
max-width: 250px; /* Controls the button size */
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1em;
}
.event-link button:hover{
color: var(--text-color);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment