Skip to content

Commit

Permalink
Merge pull request #1 from nestauk/add-barebones-texting
Browse files Browse the repository at this point in the history
Add barebones texting
  • Loading branch information
cdccollins authored Sep 19, 2024
2 parents 8487adb + 54313ba commit 653279f
Show file tree
Hide file tree
Showing 83 changed files with 1,901 additions and 113 deletions.
4 changes: 4 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
TWILIO_ACCOUNT_SID='aaaaa'
TWILIO_AUTH_TOKEN='bbbbb'
CALLBACK_URL=''
TWILIO_PHONE_NUMBER="+447111111111"
2 changes: 0 additions & 2 deletions .github/workflows/rubyonrails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,5 @@ jobs:
uses: ruby/setup-ruby@78c01b705fd9d5ad960d432d3a0cfa341d50e410 # v1.179.1
with:
bundler-cache: true
- name: Generate binstubs
run: bundle binstubs bundler-audit brakeman rubocop
- name: Lint Ruby files
run: bin/rake standard
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/.bundle

# Ignore all environment files (except templates).
/.env*
.env
!/.env*.erb

# Ignore all logfiles and tempfiles.
Expand Down
11 changes: 9 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,24 @@ group :development, :test do
end

group :development do
gem "web-console"
gem "hotwire-livereload", "~> 1.2"
gem "faker"
gem "hotwire-livereload", "~> 1.2"
gem "web-console"
end

group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem "capybara"
gem "mocha"
gem "selenium-webdriver"
gem "webmock"
end

gem "delayed_job_active_record"
gem "devise"
gem "phony_rails"
gem "positioning"
gem "sassc-rails"
gem "simple_form"
gem "tailwindcss-rails"
gem "twilio-ruby"
58 changes: 58 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ GEM
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0)
bcrypt (3.1.20)
bigdecimal (3.1.8)
bindex (0.8.1)
bootsnap (1.18.3)
Expand All @@ -95,11 +96,25 @@ GEM
xpath (~> 3.2)
concurrent-ruby (1.3.3)
connection_pool (2.4.1)
crack (1.0.0)
bigdecimal
rexml
crass (1.0.6)
date (3.3.4)
debug (1.9.2)
irb (~> 1.10)
reline (>= 0.3.8)
delayed_job (4.1.12)
activesupport (>= 3.0, < 8.0)
delayed_job_active_record (4.1.8)
activerecord (>= 3.0, < 8.0)
delayed_job (>= 3.0, < 5)
devise (4.9.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
dotenv (2.8.1)
dotenv-rails (2.8.1)
dotenv (= 2.8.1)
Expand All @@ -113,11 +128,17 @@ GEM
railties (>= 5.0.0)
faker (3.4.1)
i18n (>= 1.8.11, < 2)
faraday (2.10.1)
faraday-net_http (>= 2.0, < 3.2)
logger
faraday-net_http (3.1.1)
net-http
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
globalid (1.2.1)
activesupport (>= 6.1)
hashdiff (1.1.1)
hotwire-livereload (1.4.0)
actioncable (>= 6.0.0)
listen (>= 3.0.0)
Expand All @@ -136,6 +157,8 @@ GEM
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
json (2.7.2)
jwt (2.8.2)
base64
language_server-protocol (3.17.0.3)
lint_roller (1.1.0)
listen (3.9.0)
Expand All @@ -154,8 +177,12 @@ GEM
matrix (0.4.2)
mini_mime (1.1.5)
minitest (5.24.1)
mocha (2.4.5)
ruby2_keywords (>= 0.0.5)
msgpack (1.7.2)
mutex_m (0.2.0)
net-http (0.4.1)
uri
net-imap (0.4.14)
date
net-protocol
Expand All @@ -172,11 +199,19 @@ GEM
racc (~> 1.4)
nokogiri (1.16.6-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.25.1)
parser (3.3.4.0)
ast (~> 2.4.1)
racc
pg (1.5.6)
phony (2.20.13)
phony_rails (0.15.0)
activesupport (>= 3.0)
phony (>= 2.18.12)
positioning (0.2.6)
activerecord (>= 6.1)
activesupport (>= 6.1)
psych (5.1.2)
stringio
public_suffix (6.0.0)
Expand Down Expand Up @@ -234,6 +269,9 @@ GEM
regexp_parser (2.9.2)
reline (0.5.9)
io-console (~> 0.5)
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.3.1)
strscan
rubocop (1.64.1)
Expand All @@ -253,6 +291,7 @@ GEM
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sassc (2.4.0)
ffi (~> 1.9)
Expand Down Expand Up @@ -307,14 +346,25 @@ GEM
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
twilio-ruby (7.2.3)
faraday (>= 0.9, < 3.0)
jwt (>= 1.5, < 3.0)
nokogiri (>= 1.6, < 2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
uri (0.13.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webmock (3.23.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.1)
websocket (1.2.11)
websocket-driver (0.7.6)
Expand All @@ -326,20 +376,26 @@ GEM

PLATFORMS
aarch64-linux
arm64-darwin-22
arm64-darwin-23
x86_64-linux

DEPENDENCIES
bootsnap
capybara
debug
delayed_job_active_record
devise
dotenv-rails (~> 2.8)
factory_bot_rails
faker
hotwire-livereload (~> 1.2)
importmap-rails
jbuilder
mocha
pg (~> 1.1)
phony_rails
positioning
puma (>= 5.0)
rails (~> 7.1.3, >= 7.1.3.4)
redis (>= 4.0.1)
Expand All @@ -351,8 +407,10 @@ DEPENDENCIES
stimulus-rails
tailwindcss-rails
turbo-rails
twilio-ruby
tzinfo-data
web-console
webmock

RUBY VERSION
ruby 3.2.2p53
Expand Down
9 changes: 9 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@
require_relative "config/application"

Rails.application.load_tasks

unless Rails.env.production?
require "standard/rake"
Rake::Task["test"].enhance(%i[standard])
end

Rake::Task["test"].enhance do
Rake::Task["test:system"].invoke
end
4 changes: 4 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ h1, h2 {
h3, h4, h5, h6, p, a, span, div, li, td, th, label, input, textarea, select, button {
font-family: 'ReithSans';
}

body {
background-color: #fafafa;
}
12 changes: 5 additions & 7 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
class ApplicationController < ActionController::Base
if Rails.env == "production"
before_action :authenticate
def after_sign_up_path_for(user)
dashboard_users_path
end

def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == ENV["USERNAME"] && password == ENV["PASSWORD"]
end

def after_sign_in_path_for(user)
dashboard_users_path
end
end
45 changes: 45 additions & 0 deletions app/controllers/contents_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class ContentsController < ApplicationController
before_action :authenticate_admin!

def new
@group = Group.find_by(id: params[:group_id])
@content = @group.contents.new
end

def create
@group = Group.find_by(id: params[:group_id])
@content = @group.contents.new(content_params)

if @content.save
redirect_to group_path(@content.group), notice: "Content for message was successfully created"
else
render :new, status: :unprocessable_entity
end
end

def edit
@content = Content.find(params[:id])
end

def update
@content = Content.find(params[:id])

if @content.update(content_params)
redirect_to group_path(@content.group), notice: "Content updated!"
else
render :edit, status: :unprocessable_entity
end
end

def update_position
@content = Content.find(params[:id])
@content.update(position: params[:position])
head :no_content
end

private

def content_params
params.require(:content).permit(:body, :link, :position)
end
end
45 changes: 45 additions & 0 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class GroupsController < ApplicationController
before_action :authenticate_admin!

def index
@groups = Group.order(:age_in_months)
end

def show
@group = Group.find_by(id: params[:id])
end

def new
@group = Group.new
end

def create
@group = Group.new(group_params)

if @group.save
redirect_to groups_path, notice: "Content group successfully created"
else
render :new, status: :unprocessable_entity
end
end

def edit
@group = Group.find(params[:id])
end

def update
@group = Group.find(params[:id])

if @group.update(group_params)
redirect_to groups_path, notice: "Content group updated"
else
render :edit, status: :unprocessable_entity
end
end

private

def group_params
params.require(:group).permit(:name, :age_in_months)
end
end
Loading

0 comments on commit 653279f

Please sign in to comment.