Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daily mailer #18

Closed
wants to merge 70 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
8ebf118
Refactor: fixes dimensions to work on desktop
MWoodshop Sep 18, 2023
10ef3de
Feat: adds logic to allow users to view completed questions
MWoodshop Sep 18, 2023
91edccf
gem bcrypt
ConnorRichmond Sep 18, 2023
a421035
schema
ConnorRichmond Sep 18, 2023
0ef2a4b
route login button to login page
ConnorRichmond Sep 18, 2023
48d6805
login form
ConnorRichmond Sep 18, 2023
06b9246
account create form
ConnorRichmond Sep 18, 2023
7c02950
login and create routes
ConnorRichmond Sep 18, 2023
e5a96f4
user model
ConnorRichmond Sep 18, 2023
a1f3860
login and create methods
ConnorRichmond Sep 18, 2023
64fc8a9
redirect to game after login or login after creation
ConnorRichmond Sep 18, 2023
a8a8ffa
fix path to root after login
ConnorRichmond Sep 18, 2023
68448b9
update: login password to be hidden
ConnorRichmond Sep 18, 2023
35d1622
create user spec
ConnorRichmond Sep 18, 2023
528e76a
gem shoulda matchers
ConnorRichmond Sep 18, 2023
be79100
user model spec
ConnorRichmond Sep 18, 2023
2e950d8
login tests
ConnorRichmond Sep 18, 2023
66d2995
Feat: updats controller to submit results
MWoodshop Sep 19, 2023
8604bbb
Feat: updates game board to submit results
MWoodshop Sep 19, 2023
3096047
Updated HTML with auth token
MWoodshop Sep 19, 2023
c42ba6e
Feat: updates routes
MWoodshop Sep 19, 2023
efbe6c8
Fix: restores missing functionality to JS
MWoodshop Sep 19, 2023
e62605d
Feat: updates JS to only show override button in correct scenarios an…
MWoodshop Sep 19, 2023
e8b69a5
Feat: adds new button
MWoodshop Sep 19, 2023
df4c36f
Feat: updates override button and adds return button
MWoodshop Sep 19, 2023
00b0f8e
Feat: fixes game state not populating
MWoodshop Sep 19, 2023
487e483
Feat: updates controller
MWoodshop Sep 19, 2023
2effdbf
Feat: adds clear state debug button
MWoodshop Sep 19, 2023
7fba07b
Feat: adds debug state clear button
MWoodshop Sep 19, 2023
d1c07ab
Feat: adds debug state clear to routes
MWoodshop Sep 19, 2023
ad5b0b5
Feat: adds skipped to result
MWoodshop Sep 20, 2023
a97b13e
Feat: adds skipped to result
MWoodshop Sep 20, 2023
05da4e4
Feat: adds new controller
MWoodshop Sep 20, 2023
f360b9d
Feat: adds new JS import
MWoodshop Sep 20, 2023
8ab05f3
Feat: adds new JS file
MWoodshop Sep 20, 2023
346d662
Feat: adds new view file
MWoodshop Sep 20, 2023
624f8ff
Feat: updates routes
MWoodshop Sep 20, 2023
4dbab5a
Chore: removes code for now - will be done in Ruby
MWoodshop Sep 20, 2023
2315ee9
Feat: adds set cookie functionality to JS
MWoodshop Sep 20, 2023
c888223
Fix: swaps HTML
MWoodshop Sep 20, 2023
0fe642a
Fix: swaps HTML
MWoodshop Sep 20, 2023
f3c0528
move login button logic
ConnorRichmond Sep 20, 2023
5767801
reformat button to align with site
ConnorRichmond Sep 20, 2023
7b4a0be
User also need email when logging in
ConnorRichmond Sep 20, 2023
c2b5ceb
add email to user table
ConnorRichmond Sep 20, 2023
06fbec5
User logs in with email instead of username
ConnorRichmond Sep 20, 2023
96f80a7
session logout and route
ConnorRichmond Sep 20, 2023
c82cc05
model update for email
ConnorRichmond Sep 20, 2023
6f444d9
model validates email and username
ConnorRichmond Sep 20, 2023
d9b08f0
update logout functions
ConnorRichmond Sep 20, 2023
07bf78d
update flash handling
ConnorRichmond Sep 20, 2023
f10b115
update tests
ConnorRichmond Sep 20, 2023
dfc73f1
document broken path
ConnorRichmond Sep 20, 2023
0e3504e
Merge branch 'add_override_button' of github.com:wutz-game/wutz_fe in…
ConnorRichmond Sep 20, 2023
834cf6e
fix: syntax error
ConnorRichmond Sep 20, 2023
a464005
remove unneeded js
ConnorRichmond Sep 20, 2023
682f2f6
login form events
ConnorRichmond Sep 20, 2023
c34608f
user data
ConnorRichmond Sep 20, 2023
ff7fe9e
Sidekiq and redis gems
ConnorRichmond Sep 20, 2023
4906fac
sidekiq configure
ConnorRichmond Sep 20, 2023
0450853
mailer config
ConnorRichmond Sep 20, 2023
4d8981f
mailer controller and job
ConnorRichmond Sep 20, 2023
3d0be48
email contents
ConnorRichmond Sep 20, 2023
5267b2a
Merge branch 'login_create' of github.com:wutz-game/wutz_fe into dail…
ConnorRichmond Sep 20, 2023
8bceff2
gem fix
ConnorRichmond Sep 20, 2023
87f2626
remove unused files
ConnorRichmond Sep 20, 2023
505f0ff
email notification
ConnorRichmond Sep 20, 2023
1f5ee37
email test
ConnorRichmond Sep 20, 2023
dbea9df
Merge branch 'login_merge' of github.com:wutz-game/wutz_fe into daily…
ConnorRichmond Sep 20, 2023
b708beb
fix routing
ConnorRichmond Sep 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ gem "jbuilder"
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

gem "sidekiq"

gem "whenever", require: false

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

Expand Down Expand Up @@ -64,6 +68,8 @@ group :test do
gem "vcr"
gem "webmock"
gem "launchy"
gem 'shoulda-matchers'
gem 'factory_bot'
end

group :development do
Expand All @@ -77,3 +83,5 @@ group :development do
# gem "spring"
end

gem 'bcrypt'

21 changes: 21 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ GEM
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.1.1)
bcrypt (3.1.19)
bindex (0.8.1)
bootsnap (1.16.0)
msgpack (~> 1.2)
Expand All @@ -82,8 +83,10 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
chronic (0.10.2)
coderay (1.1.3)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
crack (0.4.5)
rexml
crass (1.0.6)
Expand All @@ -94,6 +97,8 @@ GEM
diff-lcs (1.5.0)
docile (1.4.0)
erubi (1.12.0)
factory_bot (6.3.0)
activesupport (>= 5.0.0)
faraday (2.7.11)
base64
faraday-net_http (>= 2.0, < 3.1)
Expand Down Expand Up @@ -186,6 +191,8 @@ GEM
rake (13.0.6)
rdoc (6.5.0)
psych (>= 4.0.0)
redis-client (0.17.0)
connection_pool
regexp_parser (2.8.1)
reline (0.3.8)
io-console (~> 0.5)
Expand Down Expand Up @@ -213,6 +220,13 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
shoulda-matchers (5.3.0)
activesupport (>= 5.2.0)
sidekiq (7.1.4)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.14.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -255,6 +269,8 @@ GEM
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
whenever (1.0.0)
chronic (>= 0.6.3)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.11)
Expand All @@ -264,9 +280,11 @@ PLATFORMS
arm64-darwin-22

DEPENDENCIES
bcrypt
bootsnap
capybara
debug
factory_bot
faraday
importmap-rails
jbuilder
Expand All @@ -277,6 +295,8 @@ DEPENDENCIES
rails (~> 7.0.7, >= 7.0.7.2)
rspec-rails
selenium-webdriver
shoulda-matchers
sidekiq
simplecov
sprockets-rails
stimulus-rails
Expand All @@ -286,6 +306,7 @@ DEPENDENCIES
web-console
webdrivers
webmock
whenever

RUBY VERSION
ruby 3.2.2p53
Expand Down
15 changes: 8 additions & 7 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ body {
left: 50vw;
top: 50vh;
transform: translate(-50%, -50%);
height: 100vh;
width: 100vw;
height: 100%;
width: 100%;
max-width: 500px;
margin: 0;
padding: 0;
background-color: #1F2937;
Expand Down Expand Up @@ -149,10 +150,10 @@ body {
background-color: #1F2937 ;
}

/* Submit Game Button */
#submitGameBtn {
/* Submit Game Button, Override Button */
#submitGameBtn, #overrideBtn, #returnToGameBtn {
appearance: button;
height: 25px;
height: 40px;
width: 310px;
background-color: transparent;
background-image: linear-gradient(to bottom, #cecece, #ffffff);
Expand Down Expand Up @@ -182,13 +183,13 @@ body {
align-items: center;
}

#submitGameBtn:active {
#submitGameBtn:active, #overrideBtn:active, #returnToGameBtn:active {
background-color: #f3f4f6;
box-shadow: -1px 2px 5px rgba(81,41,10,0.15),0px 1px 1px rgba(81,41,10,0.15);
transform: translateY(0.125rem);
}

#submitGameBtn:focus {
#submitGameBtn:focus, #overrideBtn:focus, #returnToGameBtn:focus {
box-shadow: rgba(72, 35, 7, .46) 0 0 0 4px, -6px 8px
}
/* Initial Popup Close Popup Button */
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
class ApplicationController < ActionController::Base
end
helper_method :current_user

def current_user
@_current_user ||= User.find(session[:user_id]) if session[:user_id]
end
end
3 changes: 3 additions & 0 deletions app/controllers/game_results_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class GameResultsController < ApplicationController
def index; end
end
41 changes: 41 additions & 0 deletions app/controllers/games_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
class GamesController < ApplicationController
skip_before_action :verify_authenticity_token, only: [:submit_result]

def index
@facade = GamesFacade.new
end

def submit_result
game_result = game_result_params

if game_result.nil?
render json: { success: false, error: 'No game_result in params' }, status: 400
return
end

user_answers = game_result[:user_answers]

if user_answers.nil?
render json: { success: false, error: 'Missing user_answers' }, status: 400
return
end

# ... add actual logic for handling the game result ...

render json: { success: true }
end

def clear_state
# Clear session, cookies, or database state here
session.clear

render json: { success: true, message: 'Server-side game state cleared' }
end

private

def game_result_params
if params[:data].present?
params.require(:data).permit(user_answers: %i[game_question_id user_answer result])
elsif params[:game] && params[:game][:data]
params.require(:game).require(:data).permit(user_answers: %i[game_question_id user_answer result])
end
rescue ActionController::ParameterMissing
nil
end
end
8 changes: 8 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class SessionsController < ApplicationController

def destroy
session.delete(:user_id)
redirect_to root_path
end

end
35 changes: 35 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class UsersController < ApplicationController
def new
@user = User.new
end

def create
new_user = User.create(user_params)
session[:user_id] = new_user.id
flash[:success] = "Welcome, #{new_user.username}!"
redirect_to root_path
end

def login_form
end

def login
user = User.find_by(email: params[:email])
if user && user.authenticate(params[:password])
session[:user_id] = user.id
@user_id = user.id
@user_name = user.username
@authenticated = true
flash[:success] = "Welcome, #{user.username}!"
redirect_to root_path
else
flash[:error] = "Sorry, your credentials are bad."
render :login_form
end
end

private
def user_params
params.require(:user).permit(:username, :email, :password)
end
end
2 changes: 2 additions & 0 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
import "@hotwired/turbo-rails"
import "controllers"
import "./game_board.js";
import "./game_results.js";
import "./login_form.js";
Loading