Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
khazelton committed Apr 4, 2019
1 parent 2f07a64 commit 3c2dc98
Showing 47 changed files with 745 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Sources/SIS/sis-app/app/assets/config/manifest.js
@@ -0,0 +1,3 @@
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
16 changes: 16 additions & 0 deletions Sources/SIS/sis-app/app/assets/javascripts/application.js
@@ -0,0 +1,16 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
13 changes: 13 additions & 0 deletions Sources/SIS/sis-app/app/assets/javascripts/cable.js
@@ -0,0 +1,13 @@
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the rails generate channel command.
//
//= require action_cable
//= require_self
//= require_tree ./channels

(function() {
this.App || (this.App = {});

App.cable = ActionCable.createConsumer();

}).call(this);
3 changes: 3 additions & 0 deletions Sources/SIS/sis-app/app/assets/javascripts/courses.coffee
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions Sources/SIS/sis-app/app/assets/javascripts/users.coffee
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
13 changes: 13 additions & 0 deletions Sources/SIS/sis-app/app/assets/stylesheets/application.css
@@ -0,0 +1,13 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*/

3 changes: 3 additions & 0 deletions Sources/SIS/sis-app/app/assets/stylesheets/courses.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the courses controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
89 changes: 89 additions & 0 deletions Sources/SIS/sis-app/app/assets/stylesheets/scaffolds.scss
@@ -0,0 +1,89 @@
body {
background-color: #fff;
color: #333;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
margin: 33px;
}

p, ol, ul, td {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;
line-height: 18px;
margin: 33px;
}

pre {
background-color: #eee;
padding: 10px;
font-size: 11px;
}

a {
color: #000;

&:visited {
color: #666;
}

&:hover {
color: #fff;
background-color: #000;
}
}

th {
padding-bottom: 5px;
}

td {
padding-bottom: 7px;
padding-left: 5px;
padding-right: 5px;
}

div {
&.field, &.actions {
margin-bottom: 10px;
}
}

#notice {
color: green;
}

.field_with_errors {
padding: 2px;
background-color: red;
display: table;
}

#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;

h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0;
background-color: #c00;
color: #fff;
}

ul li {
font-size: 12px;
list-style: square;
}
}

label {
display: block;
}
3 changes: 3 additions & 0 deletions Sources/SIS/sis-app/app/assets/stylesheets/users.scss
@@ -0,0 +1,3 @@
// Place all the styles related to the users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
4 changes: 4 additions & 0 deletions Sources/SIS/sis-app/app/channels/application_cable/channel.rb
@@ -0,0 +1,4 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
@@ -0,0 +1,4 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
3 changes: 3 additions & 0 deletions Sources/SIS/sis-app/app/controllers/application_controller.rb
@@ -0,0 +1,3 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
end
76 changes: 76 additions & 0 deletions Sources/SIS/sis-app/app/controllers/courses_controller.rb
@@ -0,0 +1,76 @@
class CoursesController < ApplicationController
before_action :set_course, only: [:show, :edit, :update, :destroy]

# GET /courses
# GET /courses.json
def index
@courses = Course.all
end

# GET /courses/1
# GET /courses/1.json
def show
end

# GET /courses/new
def new
@course = Course.new
@users = User.all
end

# GET /courses/1/edit
def edit
@users = User.all
end

# POST /courses
# POST /courses.json
def create
@course = Course.new(course_params)

respond_to do |format|
if @course.save
format.html { redirect_to @course, notice: 'Course was successfully created.' }
format.json { render :show, status: :created, location: @course }
else
format.html { render :new }
format.json { render json: @course.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /courses/1
# PATCH/PUT /courses/1.json
def update
respond_to do |format|
if @course.update(course_params)
format.html { redirect_to @course, notice: 'Course was successfully updated.' }
format.json { render :show, status: :ok, location: @course }
else
format.html { render :edit }
format.json { render json: @course.errors, status: :unprocessable_entity }
end
end
end

# DELETE /courses/1
# DELETE /courses/1.json
def destroy
@course.destroy
respond_to do |format|
format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_course
@course = Course.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def course_params
params.require(:course).permit(:course_name, :course_number, :user_ids => [])
end
end
77 changes: 77 additions & 0 deletions Sources/SIS/sis-app/app/controllers/users_controller.rb
@@ -0,0 +1,77 @@
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]

# GET /users
# GET /users.json
def index
@users = User.all
end

# GET /users/1
# GET /users/1.json
def show
end

# GET /users/new
def new
@user = User.new
@courses = Course.all
end

# GET /users/1/edit
def edit
@courses = Course.all
end

# POST /users
# POST /users.json
def create
@user = User.new(user_params)
@user.write_to_ldap

respond_to do |format|
if @user.save
format.html { redirect_to @user, notice: 'User was successfully created.' }
format.json { render :show, status: :created, location: @user }
else
format.html { render :new }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /users/1
# PATCH/PUT /users/1.json
def update
respond_to do |format|
if @user.update(user_params)
format.html { redirect_to @user, notice: 'User was successfully updated.' }
format.json { render :show, status: :ok, location: @user }
else
format.html { render :edit }
format.json { render json: @user.errors, status: :unprocessable_entity }
end
end
end

# DELETE /users/1
# DELETE /users/1.json
def destroy
@user.destroy
respond_to do |format|
format.html { redirect_to users_url, notice: 'User was successfully destroyed.' }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_user
@user = User.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def user_params
params.require(:user).permit(:uid, :givenname, :surname, :fullName, :description, :email, :password, :course_ids => [])
end
end
2 changes: 2 additions & 0 deletions Sources/SIS/sis-app/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
module ApplicationHelper
end
2 changes: 2 additions & 0 deletions Sources/SIS/sis-app/app/helpers/courses_helper.rb
@@ -0,0 +1,2 @@
module CoursesHelper
end
2 changes: 2 additions & 0 deletions Sources/SIS/sis-app/app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
module UsersHelper
end
2 changes: 2 additions & 0 deletions Sources/SIS/sis-app/app/jobs/application_job.rb
@@ -0,0 +1,2 @@
class ApplicationJob < ActiveJob::Base
end
4 changes: 4 additions & 0 deletions Sources/SIS/sis-app/app/mailers/application_mailer.rb
@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end
3 changes: 3 additions & 0 deletions Sources/SIS/sis-app/app/models/application_record.rb
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
3 changes: 3 additions & 0 deletions Sources/SIS/sis-app/app/models/course.rb
@@ -0,0 +1,3 @@
class Course < ActiveRecord::Base
has_and_belongs_to_many :users
end
38 changes: 38 additions & 0 deletions Sources/SIS/sis-app/app/models/user.rb
@@ -0,0 +1,38 @@
require 'net/ldap'

class User < ApplicationRecord
has_and_belongs_to_many :courses

def name
return givenname + " " + surname
end

def write_to_ldap
ldap_host = LDAP_CONFIG['host']
ldap_port = LDAP_CONFIG['port']
ldap_base = LDAP_CONFIG['base']
ldap_user = LDAP_CONFIG['admin']
ldap_pass = LDAP_CONFIG['pass']

# create the DN for the object
dn = "uid="+uid+","+ldap_base

# create the list of attributes for the object
attr = {
:cn => fullName,
:objectclass => ['organizationalperson','person','top','inetOrgPerson','eduPerson'],
:givenName => givenname,
:sn => surname,
:uid => uid,
:userPassword => password
}

# connect and add the entry
Net::LDAP.open( :host => ldap_host, :port => ldap_port, :base => ldap_base, :auth => { :method => :simple, :username => ldap_user, :password => ldap_pass }) do |ldap|
ldap.add( :dn => dn, :attributes => attr)
end
end



end
2 changes: 2 additions & 0 deletions Sources/SIS/sis-app/app/views/courses/_course.json.jbuilder
@@ -0,0 +1,2 @@
json.extract! course, :id, :course_name, :course_number, :created_at, :updated_at
json.url course_url(course, format: :json)

0 comments on commit 3c2dc98

Please sign in to comment.