working on authentication

pull/1/head
Jared Cosulich 9 years ago
parent a018c42e0f
commit 24280f7a68

@ -14,4 +14,8 @@ class User < ApplicationRecord
def admin?(school) def admin?(school)
schools.index(school).present? schools.index(school).present?
end end
def super_admin?
[1].index(id).present?
end
end end

@ -1,10 +1,15 @@
%h2 Forgot your password? .row
= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| .offset-sm-2.col-sm-8
= devise_error_messages! %h3 Forgot Your Password
.field = form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
= f.label :email = devise_error_messages!
%br/
= f.email_field :email, autofocus: true .form-group
.actions = f.label :email
= f.submit "Send me reset password instructions" %br/
= render "devise/shared/links" = f.email_field :email, autofocus: true, class: 'form-control'
.form-group
= f.submit "Send Me Reset Password Instructions", class: 'btn btn-primary'
= render "devise/shared/links"

@ -5,14 +5,16 @@
- if controller_name != 'sessions' - if controller_name != 'sessions'
Already have an account? Already have an account?
&nbsp;
= link_to "Log In", new_session_path(resource_name) = link_to "Log In", new_session_path(resource_name)
&nbsp; &nbsp;
&nbsp; &nbsp;
&nbsp; &nbsp;
&nbsp; &nbsp;
- if devise_mapping.registerable? && controller_name != 'registrations' -# if devise_mapping.registerable? && controller_name != 'registrations'
Don't have an account? Don't have an account?
&nbsp;
= link_to "Sign Up", new_registration_path(resource_name) = link_to "Sign Up", new_registration_path(resource_name)
&nbsp; &nbsp;
&nbsp; &nbsp;

@ -7,4 +7,4 @@
= link_to 'Sign Out', destroy_user_session_path, rel: "nofollow", method: :delete, class: 'btn btn-small grey waves-effect waves-light ' = link_to 'Sign Out', destroy_user_session_path, rel: "nofollow", method: :delete, class: 'btn btn-small grey waves-effect waves-light '
- else - else
= link_to 'Login', new_user_session_path, class: 'btn btn-small grey waves-effect waves-light ' = link_to 'Login', new_user_session_path, class: 'btn btn-small grey waves-effect waves-light '
= link_to 'Register', new_user_registration_path, class: 'btn btn-small grey waves-effect waves-light ' =# link_to 'Register', new_user_registration_path, class: 'btn btn-small grey waves-effect waves-light '

@ -13,7 +13,7 @@
%thead{style: 'font-weight: bold;'} %thead{style: 'font-weight: bold;'}
%th Name %th Name
%th{colspan: 2} %th{colspan: 2}
- current_user.schools.each do |school| - current_user.schools.each do |school|
%tr.school %tr.school
%td= link_to school.name, school %td= link_to school.name, school
%td= link_to('Admin', school_admin_path(school)) %td= link_to('Admin', school_admin_path(school))

@ -1,17 +1,27 @@
.row - if user_signed_in? && current_user.super_admin?
.col-12 .row.super-admin
%p= link_to "Create A New District", new_district_path .col-12
%p= link_to "Create A New District", new_district_path
%p= link_to "Create A New School", new_school_path %p= link_to "Create A New School", new_school_path
.row.mt-3 - if user_signed_in?
.col-6 .row.mt-3
%h4 Districts -# .col-6
- @districts.each do |district| -# %h4 Districts
%p= link_to district.name, district -# - @districts.each do |district|
-# %p= link_to district.name, district
.col-6 .col-6
%h4 Schools %h4 Schools
- @schools.each do |school| - current_user.schools.each do |school|
%p= link_to school.name, school %p= link_to school.name, school
- else
.text-center.my-3.py-3
%h3.my-3.py-3
EdContext is currently in beta testing.
%p.py-3
If you have an account, please sign in.

@ -10,11 +10,20 @@
questions = Category.find_by_name('Family Subcategory').child_categories.map(&:questions).flatten questions = Category.find_by_name('Family Subcategory').child_categories.map(&:questions).flatten
QuestionList.create(name: 'Family Questions', question_id_array: questions.map(&:id)) QuestionList.create(name: 'Family Questions', question_id_array: questions.map(&:id))
user = User.create(email: 'jared@edcontext.org', password: '123456')
cambridge = District.create(name: 'Cambridge Public Schools') district = District.create(name: 'EdContext Test District')
school = School.create(name: 'Graham & Parks', district: cambridge, description: 'A description of G&P') school = School.create(name: 'EdContext Test School', district: district, description: 'A school used to test the EdContext System')
recipient = school.recipients.create(name: 'Jared Cosulich', phone: '650-269-3205') recipients = [
recipient_list = school.recipient_lists.create(name: 'Pilot Parent Test', recipient_id_array: [recipient.id]) school.recipients.create(name: 'Jared Cosulich', phone: '650-269-3205'),
school.recipients.create(name: 'Lauren Cosulich', phone: '6173522365'),
school.recipients.create(name: 'Jack Schneider', phone: '+1 267-968-2293'),
school.recipients.create(name: 'Lynisse Patin', phone: '19176566892'),
school.recipients.create(name: 'Khemenec Patin', phone: '(347) 534-6437'),
]
recipient_list = school.recipient_lists.create(name: 'Pilot Parent Test', recipient_id_array: recipients.map(&:id))
user.user_schools.create(school: school)
# somerville = District.create(name: 'Somerville Public Schools') # somerville = District.create(name: 'Somerville Public Schools')
# #

Loading…
Cancel
Save