From 0d597813ec552f383140b65f4b7e63c5a9b165f4 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Fri, 23 Oct 2015 19:57:32 -0500 Subject: [PATCH] user activation on creation/edit --- README.md | 12 +++++++----- app/controllers/users_controller.rb | 3 ++- app/models/person.rb | 12 ++++++++++++ app/views/users/_form.html.haml | 3 +++ app/views/users/show.html.haml | 4 ++++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 94d76bb..4a8781d 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ A simple app to send sms messages with [twillio](https://www.twilio.com/). ## Configure +- set up twilio account +- create google apps oauth app + ### Secrets file: `config/application.yml` is read at boot and shoves the values into `ENV`. @@ -13,8 +16,7 @@ A simple app to send sms messages with [twillio](https://www.twilio.com/). 3. Make *ABSOLUTE* certain that this file is not checked into your repository. ## TODO -* activation flag on user edit -* verify roles access -* application log -* task runner - delayedjob or sidekiq or activerecord newness? -* milestone 1.0.0 +- milestone 1.0.0 + - decent UX + - application log + - task runner - delayedjob or sidekiq or activerecord newness? diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ebb5741..0b86bbd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -60,7 +60,8 @@ class UsersController < ApplicationController :phone, :email, :admin, - :staff + :staff, + :active ) end end diff --git a/app/models/person.rb b/app/models/person.rb index 8aa58ba..ff9a669 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -38,6 +38,18 @@ class Person < ActiveRecord::Base activation_state == "active" end + def active + activation_state == 'active' + end + + def active=(bool) + if bool + self.activation_state = 'active' + else + self.ctivation_state = nil + end + end + private ## SorceryCore expects the model to hold a crypted_password field diff --git a/app/views/users/_form.html.haml b/app/views/users/_form.html.haml index ecaa2e2..01ee173 100644 --- a/app/views/users/_form.html.haml +++ b/app/views/users/_form.html.haml @@ -26,4 +26,7 @@ = f.label :staff = f.check_box :staff + = f.label :active + = f.check_box :active + = f.submit diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 30f5c6a..ec3f2fa 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -6,6 +6,10 @@ %p Email: #{mail_to(@user.email, nil, encode: 'hex')} %p Phone: #{number_to_phone @user.phone} #{page_link(@user)} +%p Admin: #{@user.admin?} +%p Staff: #{@user.staff?} +%p Account Active: #{@user.active?} +%p Has Signed in: #{!@user.authentications.blank?} - unless @user.children.empty? %p Children: