diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..e998eb1a473d3dae299055140cc93ed339aea720 --- /dev/null +++ b/app/controllers/events_controller.rb @@ -0,0 +1,17 @@ +class EventsController < ApplicationController + def new + @new_event_validation = EventValidation.new + @new_event_error = "" + end + + def generate_event + @new_event_validation = EventValidation.new(params["new_event_validation"].permit(:title, :description, :active, :scheduledAt, :creator, :invitees)) + if @new_event_validation.valid? + create_event(@new_event_validation) + else + puts @new_event_validation.errors.full_messages + render 'new', status: :unprocessable_entity + end + end + +end \ No newline at end of file diff --git a/app/views/events/edit.html.erb b/app/views/events/edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..a71267097bf9348c18f5a031edba9d97cd47446f --- /dev/null +++ b/app/views/events/edit.html.erb @@ -0,0 +1,74 @@ +<body> + <header class="mb-auto"> + <div> + <h3 style="color: White;" class="float-md-start mb-0" >Calendar</h3> + <nav class="nav nav-masthead justify-content-center float-md-end"> + <a class="nav-link active" aria-current="page" href="/">Home</a> + <a class="nav-link" href="/login">Login</a> + <a style="padding-right:10px;" class="nav-link" href="/sign_up">Sign up</a> + </nav> + </div> + </header> + + + <%= link_to "Back", :back, class: "btn btn-success" %> + <div class="row"> + <div class="col-md-4 offset-md-2 text-box"> + <h2 class="text-center">Edit <%= resource_name.to_s.humanize %></h2> + + <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + <div class="paragraph"> + <div class="field row", style="margin-top: 10px;"> + <%= f.label :email, class: "col-sm-4 text-sm-end"%> + <%= f.email_field :email, autofocus: true, autocomplete: "email", class:"col-sm-7" %> + </div> + + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> + <div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div> + <% end %> + + <div class="field row", style="mh3 class="text-center"> Invited Events </h3> + <p class="text-center">Events that you have been invited to will appear here</p> + </div> + <% end %> + <% if @crh3 class="text-center"> Invited Events </h3> + <p class="text-center">Events that you have been invited to will appear here</p> + </div> + <% end %> + <% if @crargin-top: 10px;> + <%= f.label :password, class: "col-sm-4 text-sm-end" %> + <div class="col-sm-7"> + <div class="row"> + <%= f.password_field :password, autocomplete: "new-password", class: "col" %> + </div> + <% if @minimum_password_length %> + <em class="row"><%= @minimum_password_length %> characters minimum</em> + <% end %> + </div> + </div> + + <div class="field row", style="margin-top: 10px;"> + <%= f.label :password_confirmation, class: "col-sm-4 text-sm-end"%><br /> + <%= f.password_field :password_confirmation, autocomplete: "new-password", class:"col-sm-7" %> + </div> + + <div class="field row", style="margin-top: 10px;" > + <%= f.label :current_password, class: "col-sm-4 text-sm-end" %> + <%= f.password_field :current_password, autocomplete: "current-password", class:"col-sm-7" %> + </div> + </div> + <div class="actions text-center"> + <%= f.submit "Update", class: "btn btn-info text-center margin_top" %> + </div> + <% end %> + </div> + <div class="col-md-4 text-box paragraph text-center"> + <h2>Cancel my account</h2> + + <p>If you want to delete your account click the button below</p> + + <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete, class:"btn btn-danger" %> + + </div> +</body> \ No newline at end of file diff --git a/app/views/events/new.html.erb b/app/views/events/new.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..cd22f8b7fba632603cba3a587c6b5104439d05dd --- /dev/null +++ b/app/views/events/new.html.erb @@ -0,0 +1,64 @@ +<body> + <header class="mb-auto"> + <div style="padding-left:20px;"> + <a href = "/"><%= image_tag("Logo.png", width: '50px')%></a> + <nav class="nav nav-masthead justify-content-center float-md-end"> + <a class="nav-link active" aria-current="page" href="/">Home</a> + <a class="nav-link" href="/home/reminder_email_test">Reminder</a> + <a class="nav-link" href="/home/test_auth">Auth</a> + <a class="nav-link" href="/home/invite_test">Invite</a> + <a class="nav-link" href="/create_event">Create Event</a> + <a class="nav-link" href="/home/events_test">Get My Events</a> + <a class="nav-link" href="/home/update_event_test">Update Event</a> + <a style="padding-right:10px;" class="nav-link" href="/home/test_log_out">Log out</a> + </nav> + </div> + </header> + <div class="row pt-5"> + <div class="col-md-6 offset-md-3 text-box"> + <h3 class="text-center", style="color: White;">Create Event</h3> + + <%= form_for @new_event_validation, as: :new_event_validation, url: create_event_send_path do |f| %> + <div class="paragraph"> + <div class="field row", style="margin-top: 10px;"> + <%= f.label :title, "Title:", class: "form-label col-sm-4 text-sm-end" %> + <%= f.text_field :title, class:"col-sm-7", required: true %> + </div> + + <div class="field row", style="margin-top: 10px;"> + <%= f.label :description, "Description:", class: "form-label col-sm-4 text-sm-end" %> + <%= f.text_field :description, class:"col-sm-7", required: true %> + </div> + + <div class="field row", style="margin-top: 10px;"> + <%= f.label :active, "Active:", class: "form-label col-sm-4 text-sm-end" %> + <%= f.text_field :active, class:"col-sm-7", required: true %> + </div> + + <div class="field row", style="margin-top: 10px;"> + <%= f.label :scheduledAt, "Scheduled at:", class: "form-label col-sm-4 text-sm-end" %> + <%= f.text_field :scheduledAt, class:"col-sm-7", required: true %> + </div> + + <div class="field row", style="margin-top: 10px;"> + <%= f.label :creator, "Creator:", class: "form-label col-sm-4 text-sm-end" %> + <%= f.text_field :creator, class:"col-sm-7", required: true %> + </div> + + <div class="field row", style="margin-top: 10px;"> + <%= f.label :invitees, "Invites:", class: "form-label col-sm-4 text-sm-end" %> + <%= f.text_field :invitees, class:"col-sm-7", required: true %> + </div> + + + + + + <div class="actions text-center"> + <%= submit_tag "Create Event", class: "btn btn-success text-center margin_top" %> + </div> + </div> + <% end %> + </div> + </div> +</body> diff --git a/app/views/home/home.html.erb b/app/views/home/home.html.erb index ad8485cf9171db89db7d9c0fcc9beccef0102887..8ef3d4a0010ffd6dfafc957938ba4c6001530b06 100644 --- a/app/views/home/home.html.erb +++ b/app/views/home/home.html.erb @@ -31,7 +31,7 @@ <a class="nav-link" href="/home/reminder_email_test">Reminder</a> <a class="nav-link" href="/home/test_auth">Auth</a> <a class="nav-link" href="/home/invite_test">Invite</a> - <a class="nav-link" href="/home/event_test">Create Event</a> + <a class="nav-link" href="/create_event">Create Event</a> <a class="nav-link" href="/home/events_test">Get My Events</a> <a class="nav-link" href="/home/update_event_test">Update Event</a> <a style="padding-right:10px;" class="nav-link" href="/home/test_log_out">Log out</a> diff --git a/app/views/registrations/edit.html.erb b/app/views/registrations/edit.html.erb index f4065336e16925cd45b2c84aa5f90dfdba3c3cdb..a71267097bf9348c18f5a031edba9d97cd47446f 100644 --- a/app/views/registrations/edit.html.erb +++ b/app/views/registrations/edit.html.erb @@ -36,7 +36,7 @@ <p class="text-center">Events that you have been invited to will appear here</p> </div> <% end %> - <% if @crargin-top: 10px;"> + <% if @crargin-top: 10px;> <%= f.label :password, class: "col-sm-4 text-sm-end" %> <div class="col-sm-7"> <div class="row"> diff --git a/config/routes.rb b/config/routes.rb index 6cf66623cb4e3471a0a51859039ef46f63e71702..6d30ea1f5ed7389fda631256a3478c6c77b9d795 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,5 +26,7 @@ Rails.application.routes.draw do get 'home/created_event_test', to: 'home#created_event_test' get 'home/events_test', to: 'home#events_test' get 'home/update_event_test', to: 'home#update_event_test' + get 'create_event', to: 'events#new' + post 'create_event/send', to: 'events#generate_event' post 'delete_event_setup', to: 'home#delete_event_setup', as: 'delete_event' end