commit
f911f91da5
|
@ -13,3 +13,4 @@ node_modules
|
|||
yarn-error.log
|
||||
.byebug_history
|
||||
.env*
|
||||
.env*
|
||||
|
|
2
Gemfile
2
Gemfile
|
@ -16,6 +16,8 @@ gem 'sass-rails'
|
|||
gem 'simple_form'
|
||||
gem 'uglifier'
|
||||
gem 'webpacker'
|
||||
gem 'cloudinary'
|
||||
gem 'carrierwave', '~> 1.2'
|
||||
|
||||
group :development do
|
||||
gem 'web-console', '>= 3.3.0'
|
||||
|
|
25
Gemfile.lock
25
Gemfile.lock
|
@ -45,6 +45,7 @@ GEM
|
|||
arel (9.0.0)
|
||||
autoprefixer-rails (9.1.3)
|
||||
execjs
|
||||
aws_cf_signer (0.1.3)
|
||||
bcrypt (3.1.12)
|
||||
bindex (0.5.0)
|
||||
bootsnap (1.3.1)
|
||||
|
@ -54,6 +55,13 @@ GEM
|
|||
sass (>= 3.3.4)
|
||||
builder (3.2.3)
|
||||
byebug (10.0.2)
|
||||
carrierwave (1.2.3)
|
||||
activemodel (>= 4.0.0)
|
||||
activesupport (>= 4.0.0)
|
||||
mime-types (>= 1.16)
|
||||
cloudinary (1.9.1)
|
||||
aws_cf_signer
|
||||
rest-client
|
||||
coderay (1.1.2)
|
||||
concurrent-ruby (1.0.5)
|
||||
crass (1.0.4)
|
||||
|
@ -63,6 +71,8 @@ GEM
|
|||
railties (>= 4.1.0, < 6.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
domain_name (0.5.20180417)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
dotenv (2.5.0)
|
||||
dotenv-rails (2.5.0)
|
||||
dotenv (= 2.5.0)
|
||||
|
@ -74,6 +84,8 @@ GEM
|
|||
sassc (>= 1.11)
|
||||
globalid (0.4.1)
|
||||
activesupport (>= 4.2.0)
|
||||
http-cookie (1.0.3)
|
||||
domain_name (~> 0.5)
|
||||
i18n (1.1.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jbuilder (2.7.0)
|
||||
|
@ -90,12 +102,16 @@ GEM
|
|||
marcel (0.3.2)
|
||||
mimemagic (~> 0.3.2)
|
||||
method_source (0.9.0)
|
||||
mime-types (3.2.2)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2018.0812)
|
||||
mimemagic (0.3.2)
|
||||
mini_mime (1.0.1)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.11.3)
|
||||
msgpack (1.2.4)
|
||||
multi_json (1.13.1)
|
||||
netrc (0.11.0)
|
||||
nio4r (2.3.1)
|
||||
nokogiri (1.8.4)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
|
@ -147,6 +163,10 @@ GEM
|
|||
responders (2.4.0)
|
||||
actionpack (>= 4.2.0, < 5.3)
|
||||
railties (>= 4.2.0, < 5.3)
|
||||
rest-client (2.0.2)
|
||||
http-cookie (>= 1.0.2, < 2.0)
|
||||
mime-types (>= 1.16, < 4.0)
|
||||
netrc (~> 0.8)
|
||||
sass (3.5.7)
|
||||
sass-listen (~> 4.0.0)
|
||||
sass-listen (4.0.0)
|
||||
|
@ -183,6 +203,9 @@ GEM
|
|||
thread_safe (~> 0.1)
|
||||
uglifier (4.1.18)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.5)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
web-console (3.6.2)
|
||||
|
@ -205,6 +228,8 @@ DEPENDENCIES
|
|||
autoprefixer-rails
|
||||
bootsnap
|
||||
bootstrap-sass (~> 3.3)
|
||||
carrierwave (~> 1.2)
|
||||
cloudinary
|
||||
devise
|
||||
dotenv-rails
|
||||
font-awesome-sass (~> 5.0.9)
|
||||
|
|
|
@ -19,3 +19,4 @@ body {
|
|||
background-color: $background;
|
||||
}
|
||||
@import "devise/index";
|
||||
@import "users/index";
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
.profile-container {
|
||||
margin: 0 1in;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: calc(100vh - 4.5em); // 4.5em is height of navbar
|
||||
|
||||
form {
|
||||
flex-grow: 1;
|
||||
|
||||
.description {
|
||||
width: 100%;
|
||||
height: 5em;
|
||||
}
|
||||
}
|
||||
|
||||
.profile-pic {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-left: 3em;
|
||||
|
||||
img {
|
||||
max-width: 50vw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.profile-form {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
color: white;
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
@import "show";
|
||||
@import "edit";
|
|
@ -0,0 +1,51 @@
|
|||
.user-container {
|
||||
margin: 0 1in;
|
||||
height: calc(100vh - 4.5em); //4.5em is height of navbar.
|
||||
display:flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
|
||||
h2 {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
.profile {
|
||||
background: #33333D;
|
||||
display: flex;
|
||||
|
||||
.flex-end {
|
||||
margin-left: auto;
|
||||
display:flex;
|
||||
align-items: center;
|
||||
|
||||
a:first-child {
|
||||
margin-right: .5em;
|
||||
}
|
||||
}
|
||||
.profile-pic {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 3em;
|
||||
img {
|
||||
width: 10em;
|
||||
}
|
||||
}
|
||||
|
||||
.profile-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
h1 {
|
||||
margin: 0 0 .5em 0 ;
|
||||
}
|
||||
h2 {
|
||||
margin: 0;
|
||||
}
|
||||
.italics {
|
||||
font-style: italic;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
class UsersController < ApplicationController
|
||||
before_action :find_user, only: [:edit, :update, :show, :destroy]
|
||||
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
@user.update(user_params)
|
||||
redirect_to user_edit_path(@user)
|
||||
end
|
||||
|
||||
def create
|
||||
# Untested Code
|
||||
user = User.new(user_params)
|
||||
authorize user # I don't know where to put this TODO: Test this method
|
||||
if user.save
|
||||
redirect_to user_path(user)
|
||||
else
|
||||
raise
|
||||
end
|
||||
end
|
||||
|
||||
def show; end
|
||||
|
||||
def destroy
|
||||
@user.destroy
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_user
|
||||
@user = User.find(params[:id])
|
||||
#authorize @user
|
||||
end
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:email, :first_name, :last_name, :description, :photo)
|
||||
end
|
||||
end
|
|
@ -1,4 +1,5 @@
|
|||
class User < ApplicationRecord
|
||||
|
||||
# Include default devise modules. Others available are:
|
||||
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
|
@ -9,6 +10,8 @@ class User < ApplicationRecord
|
|||
has_many :chat_rooms, through: :chat_room_participations
|
||||
has_many :requests
|
||||
|
||||
mount_uploader :photo, PhotoUploader
|
||||
|
||||
def contacts
|
||||
self.connections.map do |connection|
|
||||
connection.contact
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class PhotoUploader < CarrierWave::Uploader::Base
|
||||
include Cloudinary::CarrierWave
|
||||
end
|
|
@ -5,11 +5,28 @@
|
|||
|
||||
<div class="right-align">
|
||||
<div class="links">
|
||||
<div class="active"><%= link_to "Dashboard", "#" %></div>
|
||||
<div class="active"><%= link_to "Dashboard", contacts_path %></div>
|
||||
<div><%= link_to "Settings", "#" %></div>
|
||||
</div>
|
||||
<div class="profile">
|
||||
<%= image_tag "https://avatars2.githubusercontent.com/u/38472180?v=4", class: "img-circle"%>
|
||||
<% if current_user.nil? %>
|
||||
<%= link_to "Login", new_user_session_path %>
|
||||
<% else %>
|
||||
<div class="dropdown">
|
||||
<div data-toggle="dropdown">
|
||||
<% if current_user.photo.url.nil? %>
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/8/89/Portrait_Placeholder.png" class="avatar dropdown-toggle img-circle">
|
||||
<% else %>
|
||||
<%= cl_image_tag current_user.photo, class: "avatar dropdown-toggle img-circle"%>
|
||||
<% end %>
|
||||
</div>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<!-- <li><a href="#">Profile</a></li> -->
|
||||
<li><%= link_to "Profile", user_path(current_user) %></li>
|
||||
<li><%= link_to "Logout", destroy_user_session_path %></li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<div class="profile-container">
|
||||
<%= simple_form_for(@user) do |t| %>
|
||||
<div class="profile-form">
|
||||
<div>
|
||||
<%= t.input :email %>
|
||||
<%= t.input :first_name %>
|
||||
<%= t.input :last_name %>
|
||||
<%= t.input :password %>
|
||||
<%= t.input :photo %>
|
||||
|
||||
<%= t.submit :Save, class: "btn btn-primary save-btn form-control" %>
|
||||
<p></p>
|
||||
<%= link_to "View my profile", user_path(@user), class: "btn btn-primary save-btn form-control" %>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="profile-pic">
|
||||
<% if @user.photo.url.nil? %>
|
||||
<%= image_tag "https://upload.wikimedia.org/wikipedia/commons/8/89/Portrait_Placeholder.png"%>
|
||||
<% else %>
|
||||
<%= cl_image_tag current_user.photo%>
|
||||
<% end %>
|
||||
|
||||
<%#= t.input_field :photo, onchange: 'this.form.submit();' %>
|
||||
<%#= t.input_field :photo, as: :hidden %>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
<h1>Users#index</h1>
|
||||
<p>Find me in app/views/users/index.html.erb</p>
|
|
@ -0,0 +1,2 @@
|
|||
<h1>Users#index</h1>
|
||||
<p>Find me in app/views/users/new.html.erb</p>
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
|
||||
|
||||
<div class="user-container">
|
||||
<div class="profile">
|
||||
<div class="profile-pic">
|
||||
<% if @user.photo.url.nil? %>
|
||||
<%= image_tag "https://upload.wikimedia.org/wikipedia/commons/8/89/Portrait_Placeholder.png", class: "img-circle"%>
|
||||
<% else %>
|
||||
<%= cl_image_tag @user.photo, class: "img-circle"%>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<div class="profile-text">
|
||||
<h1><%= @user.first_name %> <%= @user.last_name %></h1>
|
||||
<h2 class="italics" ><%= @user.email %></h2>
|
||||
</div>
|
||||
|
||||
<div class="flex-end">
|
||||
<%= link_to "Edit Information", user_edit_path(@user), class: "btn btn-primary" %>
|
||||
<%= link_to "Delete Account", user_path(@user), class: "btn btn-danger", method: :delete, data: {
|
||||
confirm: "Are you sure?"
|
||||
} %>
|
||||
</div>
|
||||
|
||||
</div>
|
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
|
@ -1 +1 @@
|
|||
WPAsr/LmaTUtdOBiiaF8pFe4kqAmEGBXZ6zurwzKhymI7lf4ObED/JfsAjZLoPy2l+i+aqponVoh1LMtMOtz9zskaf0YNNir2ybMv5ehcRjBqw/7nZKN8h4NYbw8go1M43gJsIjXjr54DIfjfFtA5NBU1zIgTQbjcLBrBwvEsxHaloRus81UKK09UyZs8wQGLWNCoMWr44dGt94UDAQ91T8qkXul31KARQHL2SqpYFzHdncduQoNAqJ2cx3tvfjr/zELt7Sa8sp+9mbBnGT4RzKNXus5yQlk+A+kbaNwTc5nD1f+6e+0XA+bL7xK63JTHktbL7hYPbL9v8oCkPRBZ7eQyCmdpzXghkxc7bXV6Afl7oQjGQlT9iuBcpmhYuu0BAtQNAduTftwe0HBoDwkTKC1aPts3dUEet0i--dX8sDZFBcdxI5Vt8--+ekAHTzodar1Ti1ZZ0w+ow==
|
||||
WPAsr/LmaTUtdOBiiaF8pFe4kqAmEGBXZ6zurwzKhymI7lf4ObED/JfsAjZLoPy2l+i+aqponVoh1LMtMOtz9zskaf0YNNir2ybMv5ehcRjBqw/7nZKN8h4NYbw8go1M43gJsIjXjr54DIfjfFtA5NBU1zIgTQbjcLBrBwvEsxHaloRus81UKK09UyZs8wQGLWNCoMWr44dGt94UDAQ91T8qkXul31KARQHL2SqpYFzHdncduQoNAqJ2cx3tvfjr/zELt7Sa8sp+9mbBnGT4RzKNXus5yQlk+A+kbaNwTc5nD1f+6e+0XA+bL7xK63JTHktbL7hYPbL9v8oCkPRBZ7eQyCmdpzXghkxc7bXV6Afl7oQjGQlT9iuBcpmhYuu0BAtQNAduTftwe0HBoDwkTKC1aPts3dUEet0i--dX8sDZFBcdxI5Vt8--+ekAHTzodar1Ti1ZZ0w+ow==
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
c8f4c6e010b5d8a06c5df4d1923a973a
|
|
@ -34,4 +34,10 @@ Rails.application.routes.draw do
|
|||
mount ActionCable.server, at: '/cable'
|
||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||
get '/home', to: 'pages#home'
|
||||
|
||||
|
||||
get '/users/:id', to: 'users#show', as: :user
|
||||
get '/users/:id/edit', to: 'users#edit', as: :user_edit
|
||||
patch '/users/:id', to: 'users#update'
|
||||
delete '/users/:id', to: 'users#destroy'
|
||||
end
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class AddFirstNameToUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :users, :first_name, :string
|
||||
add_column :users, :last_name, :string
|
||||
add_column :users, :photo, :string
|
||||
end
|
||||
end
|
|
@ -54,6 +54,9 @@ ActiveRecord::Schema.define(version: 2018_08_29_123204) do
|
|||
t.datetime "remember_created_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "first_name"
|
||||
t.string "last_name"
|
||||
t.string "photo"
|
||||
t.index ["email"], name: "index_users_on_email", unique: true
|
||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||
end
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 263 KiB |
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class UserControllerTest < ActionDispatch::IntegrationTest
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in New Issue