got rid of 'multiple' photos and logout button

This commit is contained in:
YOUR NAME 2017-11-09 18:06:08 +11:00
parent 50e6c1124e
commit dc099b4f9e
33 changed files with 391 additions and 103 deletions

6
.gitignore vendored
View file

@ -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

View file

@ -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

View file

@ -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)

BIN
app/assets/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

View file

@ -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

View file

@ -18,3 +18,7 @@
margin: auto;
width: 50%;
}
.card .card-image .card-title{
color: dodgerblue;
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,4 +1,2 @@
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -4,42 +4,80 @@
<title>Rently</title>
<%= csrf_meta_tags %>
<!-- Full version, For production do compiled and minified CSS by adding .min before .css -->
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.css"> -->
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.css">
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<%= stylesheet_link_tag "application" %>
</head>
<header>
<ul id="slide-out" class="side-nav">
<li><div class="user-view">
<div class="background">
<img src="images/me_with_mangoes1.jpg">
</div>
<img src="app/assets/images/me_with_mangoes1.jpg"><br>
</div></li>
<li><a href="#!"><i class="material-icons">cloud</i>First Link With Icon</a></li>
<li><div class="divider"></div></li>
<li><a class="waves-effect" href="#!">Third Link With Waves</a></li>
<li><!-- # views/devise/menu/_login_items.html.erb -->
<% if user_signed_in? %>
<!-- <%= link_to('Logout', destroy_user_session_path, method: :delete) %> -->
<% else %>
<%= link_to('Login', new_user_session_path) %>
<% end %></li>
<li><!-- # views/devise/menu/_registration_items.html.erb -->
<% if user_signed_in? %>
<%= link_to('Edit registration', edit_user_registration_path) %>
<% else %>
<%= link_to('Register', new_user_registration_path) %>
</li>
<% end %></li>
<li><%= link_to "Mailbox", conversations_path %><br></li>
</ul>
<a href="#" data-activates="slide-out" class="button-collapse"><i class="material-icons">menu</i></a>
</header>
<!-- <nav>
<div class="nav-wrapper">
<a href="#!" class="brand-logo">Logo</a>
<a href="#" data-activates="mobile-demo" class="button-collapse"><i class="material-icons">menu</i></a>
<ul class="right hide-on-med-and-down">
<li><a href="sass.html">Sass</a></li>
<li><a href="badges.html">Components</a></li>
<li><a href="collapsible.html">Javascript</a></li>
<li><a href="mobile.html">Mobile</a></li>
</ul>
<ul class="side-nav" id="mobile-demo">
<li><a href="sass.html">Sass</a></li>
<li><a href="badges.html">Components</a></li>
<li><a href="collapsible.html">Javascript</a></li>
<li><a href="mobile.html">Mobile</a></li>
</ul>
</div>
</nav> -->
<body>
<!--For devise to flash notices and alerts -->
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
<!-- # views/devise/menu/_login_items.html.erb -->
<% if user_signed_in? %>
<li>
<%= link_to('Logout', destroy_user_session_path, method: :delete) %>
</li>
<% else %>
<li>
<%= link_to('Login', new_user_session_path) %>
</li>
<% end %>
<!-- # views/devise/menu/_registration_items.html.erb -->
<% if user_signed_in? %>
<li>
<%= link_to('Edit registration', edit_user_registration_path) %>
</li>
<% else %>
<li>
<%= link_to('Register', new_user_registration_path) %>
</li>
<% end %>
<%= link_to "Mailbox", conversations_path %><br>
<%= yield %>
<script type="text/javascript">
$(".button-collapse").sideNav();
// Initialize collapsible (uncomment the line below if you use the dropdown variation)
//$('.collapsible').collapsible();
</script>
</body>
</html>

View file

@ -17,36 +17,6 @@
</div>
<div class="field">
<%= form.label :photo2 %>
<%= form.file_field :photo2%>
</div>
<div class="field">
<%= form.label :photo3 %>
<%= form.file_field :photo3%>
</div>
<div class="field">
<%= form.label :photo4 %>
<%= form.file_field :photo4%>
</div>
<div class="field">
<%= form.label :photo5 %>
<%= form.file_field :photo5%>
</div>
<div class="field">
<%= form.label :photo6 %>
<%= form.file_field :photo6%>
</div>
<div class="field">
<%= form.label :address %>
<%= form.text_field :address, id: :listing_Address %>

View file

@ -4,27 +4,15 @@
<table>
<thead>
<tr>
<th>Photo</th>
<th>Photo 2</th>
<th>Photo 3</th>
<th>Photo 4</th>
<th>Photo 5</th>
<th>Photo 6</th>
<th>Address</th>
<th>Property type</th>
<th>Number of bedrooms</th>
<th>Number of bathrooms</th>
<th>Max price per week</th>
<th>Available date</th>
<th>Roles</th>
<th colspan="3"></th
</tr>
<div class="responsive-table highlight">
</div>
</thead>
<body>
<% @listings.each do |listing| %>
<div class="row">
<!-- <div class="row">
<div class="col s12 m6">
<div class="card">
<div class="card-image">
@ -37,14 +25,27 @@
</div>
</div>
</div>
</div> -->
<!-- ########################################################################### -->
<div class="row">
<div class="col s12 m12 offset-m3">
<div class="card">
<div class="card-image">
<%= link_to cl_image_tag(listing.photo_url, :class => "uploaded_photo"), listing %>
<span class="card-title">$<%= listing.max_price_per_week %></span>
<a class="btn-floating halfway-fab waves-effect waves-light red"><i class="material-icons">fav</i></a>
</div>
<div class="card-content">
<%= listing.number_of_bedrooms %>
<%= listing.number_of_bathrooms %>
<%= listing.max_price_per_week %>
<p>I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively.</p>
</div>
</div>
</div>
</div>
<!-- <tr>
<td><%= cl_image_tag(listing.photo_url, :class => "uploaded_photo") %></td>
<td><%= cl_image_tag(listing.photo2_url, :class => "uploaded_photo") %></td>
<td><%= cl_image_tag(listing.photo3_url, :class => "uploaded_photo") %></td>
<td><%= cl_image_tag(listing.photo4_url, :class => "uploaded_photo") %></td>
<td><%= cl_image_tag(listing.photo5_url, :class => "uploaded_photo") %></td>
<td><%= cl_image_tag(listing.photo6_url, :class => "uploaded_photo") %></td>
<td><%= listing.address %></td>
<td><%= listing.property_type %></td>
<td><%= listing.number_of_bedrooms %></td>

View file

@ -0,0 +1,10 @@
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>Thanks for signing up, <%= @user %>!</h1>
<p>Thanks for joining and have a great day! Now sign in and do
awesome things!</p>
</body>
</html>

View file

@ -3,3 +3,13 @@ require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
ActionMailer::Base.smtp_settings = {
:user_name => "najomar68@gmail.com",
:password => "sendgridpass123",
:domain => 'localhost:3000',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}

View file

@ -1,6 +1,6 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true

View file

@ -7,7 +7,7 @@ Devise.setup do |config|
# Devise will use the `secret_key_base` as its `secret_key`
# by default. You can change it below and use your own secret key.
# config.secret_key = 'ba1b4c994337016c2f0f52f629a4d98ee3cbb840a49afeff90a50b2fd87371b20a0df1621fe1517a51e54dd8053033215094b92532ca0d408ce93d6848099b1b'
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class

View file

@ -1,13 +1,17 @@
Rails.application.routes.draw do
resources :listings
devise_for :users
#configured for users, and sendgrid hello email through devise registartions
devise_for :users, controllers: { registrations: 'users/registrations', sessions: 'users/sessions' }
get 'home/index'
resources :listings
resources :conversations do
resources :messages
end
root to: "home#index"
root to: "listings#index"
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end

View file

@ -30,3 +30,6 @@ test:
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
SENDGRID_USERNAME: 'najomar68@gmail.com'
SENDGRID_PASSWORD: 'sendgridpass123'

1
config/secrets.yml.enc Normal file
View file

@ -0,0 +1 @@
E07gxvW5WZ+yF/M3UgFiIM4dFFx2HSPM0pyJNptteTIU0eTUiNU0QiTLhJCY92gPgIVbrQUv2psArOPftwmIc76QW/5ZqafdltcMalvq3wH6xdq/En3nP9lig2eojsMFUKWI+9ZrOavlP5Exauvcypj1ABx3Xye4cgJaNFHdVFfhgDgWcSj8V5iwV287C9E2O08=--y0FB999tuhbgLJ6/--WqjRmzFtWEn0PzJ0S4DcOA==

View file

@ -1,7 +1,7 @@
class Users < ActiveRecord::Migration[5.1]
def change
create_table :users do |t|
t.name
t.timestamps
end
end

View file

@ -2,7 +2,6 @@ class CreateListings < ActiveRecord::Migration[5.1]
def change
create_table :listings do |t|
t.text :photo
t.text :photo2
t.string :address
t.string :property_type
t.integer :number_of_bedrooms

View file

@ -24,7 +24,6 @@ ActiveRecord::Schema.define(version: 20171108052557) do
create_table "listings", force: :cascade do |t|
t.text "photo"
t.text "photo2"
t.string "address"
t.string "property_type"
t.integer "number_of_bedrooms"

View file

@ -0,0 +1,4 @@
# Preview all emails at http://localhost:3000/rails/mailers/user_notifier
class UserNotifierPreview < ActionMailer::Preview
end

View file

@ -0,0 +1,5 @@
require "rails_helper"
RSpec.describe UserNotifierMailer, type: :mailer do
pending "add some examples to (or delete) #{__FILE__}"
end