Commit 9af0b513 authored by Miguel Urbina's avatar Miguel Urbina
Browse files

Merge branch 'development' into 'master'

Uploading development changes to master (staging a production)

See merge request !13
parents 26396256 9f27605c
Pipeline #41901 passed with stages
in 2 minutes and 32 seconds
......@@ -4,6 +4,8 @@
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
.envrc
# Ignore bundler config.
/.bundle
......
inherit_from: .rubocop_todo.yml
Style/Documentation:
Enabled: false
Layout/EndOfLine:
Enabled: False
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2021-08-25 05:43:52 UTC using RuboCop version 1.19.1.
# on 2021-08-30 20:27:19 UTC using RuboCop version 1.19.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
......@@ -14,6 +14,14 @@ Bundler/OrderedGems:
Exclude:
- 'Gemfile'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: outdent, indent
Layout/AccessModifierIndentation:
Exclude:
- 'app/controllers/application_controller.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
......@@ -37,6 +45,27 @@ Layout/EmptyLineAfterGuardClause:
Exclude:
- 'bin/bundle'
# Offense count: 1
# Cop supports --auto-correct.
Layout/EmptyLines:
Exclude:
- 'db/migrate/20210827051327_devise_create_users.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, no_empty_lines
Layout/EmptyLinesAroundBlockBody:
Exclude:
- 'db/schema.rb'
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Exclude:
- 'app/controllers/application_controller.rb'
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
......@@ -61,6 +90,21 @@ Layout/MultilineOperationIndentation:
Layout/SpaceInsideArrayLiteralBrackets:
Exclude:
- 'config/environments/production.rb'
- 'db/migrate/20210902100541_create_active_storage_tables.active_storage.rb'
# Cop supports --auto-correct.
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Exclude:
- 'config/environments/development.rb'
# Offense count: 2
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 26
Exclude:
- 'db/schema.rb'
# Offense count: 1
# Configuration parameters: IgnoredMethods.
......@@ -71,6 +115,9 @@ Metrics/CyclomaticComplexity:
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 13
Exclude:
- 'db/migrate/20210902100541_create_active_storage_tables.active_storage.rb'
# Offense count: 1
# Configuration parameters: IgnoredMethods.
......@@ -102,7 +149,7 @@ Style/ExpandPathArguments:
Exclude:
- 'bin/bundle'
# Offense count: 40
# Offense count: 47
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
......@@ -128,6 +175,13 @@ Style/InverseMethods:
Exclude:
- 'bin/yarn'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: MinDigits, Strict.
Style/NumericLiterals:
Exclude:
- 'db/schema.rb'
# Offense count: 1
# Cop supports --auto-correct.
Style/PerlBackrefs:
......@@ -154,23 +208,37 @@ Style/StderrPuts:
Exclude:
- 'bin/yarn'
# Offense count: 89
# Offense count: 114
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Enabled: false
# Offense count: 3
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: MinSize.
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: brackets
Exclude:
- 'db/migrate/20210902100541_create_active_storage_tables.active_storage.rb'
# Offense count: 2
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 198
Layout/SpaceInsidePercentLiteralDelimiters:
Exclude:
- 'db/migrate/20210902100541_create_active_storage_tables.active_storage.rb'
Metrics/AbcSize:
Exclude:
- 'db/migrate/20210902100541_create_active_storage_tables.active_storage.rb'
Style/WordArray:
Exclude:
- 'db/schema.rb'
......@@ -28,6 +28,11 @@ gem 'jbuilder', '~> 2.7'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false
gem 'devise'
gem 'active_storage_validations'
gem 'image_processing', '~> 1.2'
gem 'aws-sdk-s3', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
......
......@@ -39,6 +39,8 @@ GEM
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_storage_validations (0.9.5)
rails (>= 5.2.0)
activejob (6.1.4.1)
activesupport (= 6.1.4.1)
globalid (>= 0.3.6)
......@@ -63,6 +65,23 @@ GEM
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
aws-eventstream (1.2.0)
aws-partitions (1.495.0)
aws-sdk-core (3.121.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.48.0)
aws-sdk-core (~> 3, >= 3.120.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.102.0)
aws-sdk-core (~> 3, >= 3.120.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
aws-sigv4 (1.4.0)
aws-eventstream (~> 1, >= 1.0.2)
bcrypt (3.1.16)
bindex (0.8.1)
bootsnap (1.7.7)
msgpack (~> 1.0)
......@@ -79,14 +98,24 @@ GEM
childprocess (3.0.0)
concurrent-ruby (1.1.9)
crass (1.0.6)
devise (4.8.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
erubi (1.10.0)
ffi (1.15.3)
globalid (0.5.2)
activesupport (>= 5.0)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
image_processing (1.12.1)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
jbuilder (2.11.2)
activesupport (>= 5.0.0)
jmespath (1.4.0)
listen (3.7.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
......@@ -97,12 +126,14 @@ GEM
mini_mime (>= 0.1.1)
marcel (1.0.1)
method_source (1.0.0)
mini_magick (4.11.0)
mini_mime (1.1.1)
minitest (5.14.4)
msgpack (1.4.2)
nio4r (2.5.8)
nokogiri (1.12.3-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.20.1)
parser (3.0.2.0)
ast (~> 2.4.1)
......@@ -150,6 +181,9 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (2.1.1)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.5)
rubocop (1.19.1)
parallel (~> 1.10)
......@@ -163,6 +197,8 @@ GEM
rubocop-ast (1.11.0)
parser (>= 3.0.1.1)
ruby-progressbar (1.11.0)
ruby-vips (2.1.3)
ffi (~> 1.12)
rubyzip (2.3.2)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
......@@ -194,6 +230,8 @@ GEM
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (2.0.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.1.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
......@@ -219,9 +257,13 @@ PLATFORMS
x86_64-linux
DEPENDENCIES
active_storage_validations
aws-sdk-s3
bootsnap (>= 1.4.4)
byebug
capybara (>= 3.26)
devise
image_processing (~> 1.2)
jbuilder (~> 2.7)
listen (~> 3.3)
pg
......
// Place all the styles related to the Authentications controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
// Place all the styles related to the Home controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
label{
display: block;
}
.margin-left{
margin-left: 3rem;
}
.profile-picture-w-20{
width: 20%;
}
.grid-container{
display: grid;
grid-template-columns: 50% 50%;
}
.page-division{
border-right: 1px solid black;
}
.items-center{
margin-left: 20%;
}
\ No newline at end of file
// Place all the styles related to the Profile controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
.container-space-from-the-edge{
margin-bottom: 3rem;
margin-left: 3rem;
}
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protect_from_forgery with: :exception
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up) do |u|
u.permit(:first_name, :username, :birthday, :email, :password, :password_confirmation, :interests, :biography, :profile_picture)
end
devise_parameter_sanitizer.permit(:account_update) do |u|
u.permit(:first_name, :username, :birthday, :email, :password, :password_confirmation, :interests,
:biography, :phone_number, :location, :distance_preference, :looking_for,
:minimum_age, :maximum_age, :current_password, :profile_picture, :country, :city)
end
end
end
class AuthenticationsController < ApplicationController
before_action :authenticate_user!
end
class DislikesController < ApplicationController
def create
@dislike = Dislike.new(dislike_params)
if @dislike.save
flash[:notice] = 'Dislike successful'
redirect_to root_path
else
flash[:alert] = 'Dislike no success'
redirect_to root_path(@dislike)
end
end
private
def dislike_params
params.require(:dislike).permit(:user_id, :disliked_user_id)
end
end
class HomeController < ApplicationController
def index
@possible_match = find_possible_match.first if user_signed_in?
@match_users = current_user.match_users if user_signed_in?
end
private
def find_possible_match
User.where.not(id: liked_users_id + disliked_users_id + [current_user.id])
end
def liked_users_id
Like.where(user_id: current_user.id).map(&:liked_user_id)
end
def disliked_users_id
Dislike.where(user_id: current_user.id).map(&:disliked_user_id)
end
end
class LikesController < ApplicationController
def create # rubocop:disable Metrics/AbcSize
@like = Like.new(like_params)
if @like.save
flash[:notice] = 'Like successful'
got_liked_user = User.find_by(id: like_params[:liked_user_id])
like_exists = Like.exists?(liked_user_id: current_user.id, user_id: got_liked_user.id)
Match.create(user_one: got_liked_user, user_two: current_user) if like_exists
redirect_to root_path
else
flash[:alert] = 'Like no success'
redirect_to root_path(@like)
end
end
private
def like_params
params.require(:like).permit(:user_id, :liked_user_id)
end
end
class ProfileController < AuthenticationsController
def show
@user = User.find_by_username(params[:username])
redirect_to root_path unless @user
end
end
class Dislike < ApplicationRecord
validates_uniqueness_of :disliked_user_id, scope: :user_id
belongs_to :user
belongs_to :disliked_user, class_name: 'User'
end
class Like < ApplicationRecord
validates_uniqueness_of :liked_user_id, scope: :user_id
belongs_to :user
belongs_to :liked_user, class_name: 'User'
end
class Match < ApplicationRecord
belongs_to :user_one, class_name: 'User', foreign_key: :user_one_id
belongs_to :user_two, class_name: 'User', foreign_key: :user_two_id
end
class User < ApplicationRecord
has_one_attached :profile_picture
# Likes
has_many :likes
has_many :likes_received, class_name: 'Like', foreign_key: 'liked_user_id'
has_many :liked_users, through: :likes, primary_key: 'user_id', foreign_key: 'liked_user_id'
has_many :users_who_liked, through: :likes_received, source: :user
# Dislikes
has_many :dislikes
has_many :dislikes_received, class_name: 'Dislike', foreign_key: 'disliked_user_id'
has_many :disliked_users, through: :dislikes, primary_key: 'user_id', foreign_key: 'disliked_user_id'
has_many :users_who_disliked, through: :dislikes_received, source: :user
# Matches
has_many :matches_one, class_name: "Match", foreign_key: 'user_one_id', dependent: :destroy
has_many :matched_users_one, through: :matches_one, primary_key: 'user_one_id', foreign_key: 'user_two_id', source: :user_two
has_many :matches_two, class_name: "Match", foreign_key: 'user_two_id', dependent: :destroy
has_many :matched_users_two, through: :matches_two, source: :user_one
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
validates :birthday, presence: true
validates :username, :email, presence: true, uniqueness: true
validates :profile_picture, content_type: ["image/jpeg", "image/png", "image/jpg"]
def age
((Date.today - birthday.to_date) / 365).floor
end
def match_users
matched_users_one + matched_users_two
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment