diff --git a/.gitignore b/.gitignore index 82701fe..0dbd144 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,9 @@ /yarn-error.log .byebug_history +/config/local_env.yml +/config/cloudinary.yml +/config/secrets.yml + +# Ignore encrypted secrets key file. +config/secrets.yml.key diff --git a/Gemfile b/Gemfile index dbaac1c..d8df912 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,11 @@ end # for styling # gem 'semantic-ui-sass', github: 'doabit/semantic-ui-sass' +#Materialize for styling +# gem 'materialize-sass' + +#Using sendgrid as mailer +gem 'sendgrid-ruby' #File uploads rails gem gem 'carrierwave' #Cloud storage for file uploads, created an account on cloudinary diff --git a/Gemfile.lock b/Gemfile.lock index 6c528f9..8bd060c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -109,6 +109,7 @@ GEM mini_portile2 (2.3.0) minitest (5.10.3) multi_json (1.12.2) + mustermann (1.0.1) netrc (0.11.0) nio4r (2.1.0) nokogiri (1.8.1) @@ -120,6 +121,8 @@ GEM public_suffix (3.0.0) puma (3.10.0) rack (2.0.3) + rack-protection (2.0.0) + rack rack-test (0.7.0) rack (>= 1.0, < 3) rails (5.1.4) @@ -174,6 +177,7 @@ GEM rspec-support (~> 3.7.0) rspec-support (3.7.0) ruby_dep (1.5.0) + ruby_http_client (3.3.0) rubyzip (1.2.1) sass (3.5.3) sass-listen (~> 4.0.0) @@ -189,6 +193,14 @@ GEM selenium-webdriver (3.6.0) childprocess (~> 0.5) rubyzip (~> 1.0) + sendgrid-ruby (5.2.0) + ruby_http_client (~> 3.2) + sinatra (>= 1.4.7, < 3) + sinatra (2.0.0) + mustermann (~> 1.0) + rack (~> 2.0) + rack-protection (= 2.0.0) + tilt (~> 2.0) spring (2.0.2) activesupport (>= 4.2) spring-watcher-listen (2.0.1) @@ -247,6 +259,7 @@ DEPENDENCIES rspec-rails (~> 3.6) sass-rails (~> 5.0) selenium-webdriver + sendgrid-ruby spring spring-watcher-listen (~> 2.0.0) turbolinks (~> 5) diff --git a/app/assets/.DS_Store b/app/assets/.DS_Store new file mode 100644 index 0000000..cd3a2cf Binary files /dev/null and b/app/assets/.DS_Store differ diff --git a/app/assets/images/me_with_mangoes1.jpg b/app/assets/images/me_with_mangoes1.jpg new file mode 100644 index 0000000..25321fe Binary files /dev/null and b/app/assets/images/me_with_mangoes1.jpg differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 46b2035..ea5d589 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -9,7 +9,5 @@ // // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. -// -//= require rails-ujs -//= require turbolinks //= require_tree . +// Initialize collapse button diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index cb6cc83..52064e5 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -18,3 +18,7 @@ margin: auto; width: 50%; } + + .card .card-image .card-title{ + color: dodgerblue; + } diff --git a/app/controllers/listings_controller.rb b/app/controllers/listings_controller.rb index b0f989e..54659af 100644 --- a/app/controllers/listings_controller.rb +++ b/app/controllers/listings_controller.rb @@ -1,7 +1,7 @@ class ListingsController < ApplicationController before_action :set_listing, only: [:show, :edit, :update, :destroy] #Configure for petergates roles "access all" - access all: [:show, :index, :new, :edit, :create, :update ], user: {except: [:destroy, ]}, message: "You shall not pass", admin: :all + access all: [:show, :index, :new, :edit, :create, :update, ], user: {except: [:destroy, ]}, message: "You shall not pass", admin: :all # params.require(:listing).permit({photo: []}) @@ -73,6 +73,6 @@ class ListingsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def listing_params - params.require(:listing).permit(:photo, :photo2, :address, :property_type, :number_of_bedrooms, :number_of_bathrooms, :max_price_per_week, :available_date, :roles) + params.require(:listing).permit(:photo, :address, :property_type, :number_of_bedrooms, :number_of_bathrooms, :max_price_per_week, :available_date, :roles) end end diff --git a/app/controllers/users/confirmations_controller.rb b/app/controllers/users/confirmations_controller.rb new file mode 100644 index 0000000..1126e23 --- /dev/null +++ b/app/controllers/users/confirmations_controller.rb @@ -0,0 +1,28 @@ +class Users::ConfirmationsController < Devise::ConfirmationsController + # GET /resource/confirmation/new + # def new + # super + # end + + # POST /resource/confirmation + # def create + # super + # end + + # GET /resource/confirmation?confirmation_token=abcdef + # def show + # super + # end + + # protected + + # The path used after resending confirmation instructions. + # def after_resending_confirmation_instructions_path_for(resource_name) + # super(resource_name) + # end + + # The path used after confirmation. + # def after_confirmation_path_for(resource_name, resource) + # super(resource_name, resource) + # end +end diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb new file mode 100644 index 0000000..1907e5b --- /dev/null +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -0,0 +1,28 @@ +class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController + # You should configure your model like this: + # devise :omniauthable, omniauth_providers: [:twitter] + + # You should also create an action method in this controller like this: + # def twitter + # end + + # More info at: + # https://github.com/plataformatec/devise#omniauth + + # GET|POST /resource/auth/twitter + # def passthru + # super + # end + + # GET|POST /users/auth/twitter/callback + # def failure + # super + # end + + # protected + + # The path used when OmniAuth fails + # def after_omniauth_failure_path_for(scope) + # super(scope) + # end +end diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb new file mode 100644 index 0000000..53cc34e --- /dev/null +++ b/app/controllers/users/passwords_controller.rb @@ -0,0 +1,32 @@ +class Users::PasswordsController < Devise::PasswordsController + # GET /resource/password/new + # def new + # super + # end + + # POST /resource/password + # def create + # super + # end + + # GET /resource/password/edit?reset_password_token=abcdef + # def edit + # super + # end + + # PUT /resource/password + # def update + # super + # end + + # protected + + # def after_resetting_password_path_for(resource) + # super(resource) + # end + + # The path used after sending reset password instructions + # def after_sending_reset_password_instructions_path_for(resource_name) + # super(resource_name) + # end +end diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb new file mode 100644 index 0000000..b2d636d --- /dev/null +++ b/app/controllers/users/registrations_controller.rb @@ -0,0 +1,62 @@ +class Users::RegistrationsController < Devise::RegistrationsController + # before_action :configure_sign_up_params, only: [:create] + # before_action :configure_account_update_params, only: [:update] + + # GET /resource/sign_up + # def new + # super + # end + + # POST /resource + def create + super do |user| + UserNotifierMailer.send_signup_email(user).deliver + end + end + + # GET /resource/edit + # def edit + # super + # end + + # PUT /resource + # def update + # super + # end + + # DELETE /resource + # def destroy + # super + # end + + # GET /resource/cancel + # Forces the session data which is usually expired after sign + # in to be expired now. This is useful if the user wants to + # cancel oauth signing in/up in the middle of the process, + # removing all OAuth session data. + # def cancel + # super + # end + + # protected + + # If you have extra params to permit, append them to the sanitizer. + # def configure_sign_up_params + # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute]) + # end + + # If you have extra params to permit, append them to the sanitizer. + # def configure_account_update_params + # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute]) + # end + + # The path used after sign up. + # def after_sign_up_path_for(resource) + # super(resource) + # end + + # The path used after sign up for inactive accounts. + # def after_inactive_sign_up_path_for(resource) + # super(resource) + # end +end diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb new file mode 100644 index 0000000..ba03dbf --- /dev/null +++ b/app/controllers/users/sessions_controller.rb @@ -0,0 +1,25 @@ +class Users::SessionsController < Devise::SessionsController + # before_action :configure_sign_in_params, only: [:create] + + # GET /resource/sign_in + # def new + # super + # end + + # POST /resource/sign_in + # def create + # super + # end + + # DELETE /resource/sign_out + # def destroy + # super + # end + + # protected + + # If you have extra params to permit, append them to the sanitizer. + # def configure_sign_in_params + # devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute]) + # end +end diff --git a/app/controllers/users/unlocks_controller.rb b/app/controllers/users/unlocks_controller.rb new file mode 100644 index 0000000..8b9ef86 --- /dev/null +++ b/app/controllers/users/unlocks_controller.rb @@ -0,0 +1,28 @@ +class Users::UnlocksController < Devise::UnlocksController + # GET /resource/unlock/new + # def new + # super + # end + + # POST /resource/unlock + # def create + # super + # end + + # GET /resource/unlock?unlock_token=abcdef + # def show + # super + # end + + # protected + + # The path used after sending unlock password instructions + # def after_sending_unlock_instructions_path_for(resource) + # super(resource) + # end + + # The path used after unlocking the resource + # def after_unlock_path_for(resource) + # super(resource) + # end +end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 286b223..ead50cd 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,2 @@ class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' - layout 'mailer' end diff --git a/app/mailers/user_notifier_mailer.rb b/app/mailers/user_notifier_mailer.rb new file mode 100644 index 0000000..41cdc6e --- /dev/null +++ b/app/mailers/user_notifier_mailer.rb @@ -0,0 +1,10 @@ +class UserNotifierMailer < ApplicationMailer + default :from => 'any_from_address@example.com' + +# send a signup email to the user, pass in the user object that contains the user's email address + def send_signup_email(user) + @user = user + mail( :to => @user.email, + :subject => 'Thanks for signing up for our amazing app' ) + end +end diff --git a/app/models/listing.rb b/app/models/listing.rb index 39ab016..bbc3a0d 100644 --- a/app/models/listing.rb +++ b/app/models/listing.rb @@ -1,9 +1,4 @@ class Listing < ApplicationRecord attr_accessor :photo mount_uploader :photo, PhotosForListingsUploader - mount_uploader :photo2, PhotosForListingsUploader - mount_uploader :photo3, PhotosForListingsUploader - mount_uploader :photo4, PhotosForListingsUploader - mount_uploader :photo5, PhotosForListingsUploader - mount_uploader :photo6, PhotosForListingsUploader end diff --git a/app/models/user.rb b/app/models/user.rb index 44a01de..f1969a7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,9 +6,21 @@ class User < ApplicationRecord ## The multiple option can be set to true if you need users to have multiple roles. ## petergate(roles: [:admin, ], multiple: false) ## ############################################################################################ - + #For internal messaging between sender and receiver has_many :conversations, :foreign_key => :sender_id + def create + # Create the user from params + @user = User.new(params[:user]) + if @user.save + # Deliver the signup email + UserNotifier.send_signup_email(@user).deliver + redirect_to(@user, :notice => 'User created') + else + render :action => 'new' + end + end + # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 81dc940..d055491 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,42 +4,80 @@
+ 
<%= notice %>
<%= alert %>
- - - <% if user_signed_in? %> -