Skip to content

Loading…

Frontend #1

Merged
merged 11 commits into from

2 participants

@amikhile

Adding departments table,
Sorting users by name + last name
Adding dropdown menu for secondary tasks

@ramigg

Please remove this empty file

@ramigg

Please remove this empty file

@ramigg

Why did you move this file to be here?

@ramigg

What happened here? RSS catalog is catalog named 'Video' and it is not necessary has ID 1.

I don't know where it is comes from, I don't see it in the local /remote repository, maybe it is removed in the next merges after adding department

@ramigg

Please remove these 2 empty lines and also comment on line #8

@ramigg ramigg merged commit d011da6 into Bnei-Baruch:frontend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 13, 2012
  1. @amikhile
  2. @amikhile
  3. @amikhile
Commits on Feb 19, 2012
  1. @amikhile
Commits on Mar 19, 2012
  1. @amikhile

    Adding departments

    amikhile committed
  2. @amikhile

    Merge remote-tracking branch 'upstream/frontend' into frontend

    amikhile committed
    Conflicts:
    	app/views/admin/lessons/_form.html.haml
    	db/seeds.rb
Commits on Mar 20, 2012
  1. @amikhile

    removing utf8 option on create

    amikhile committed
    and fixing show user
Commits on Mar 26, 2012
  1. @amikhile

    Fixing the drop down menu css

    amikhile committed
Commits on Mar 27, 2012
  1. @amikhile

    fixing rollback

    amikhile committed
Commits on Apr 1, 2012
  1. @amikhile

    removing empty file

    amikhile committed
  2. @amikhile
View
4 .gitignore
@@ -13,5 +13,5 @@ config/database.yml
*.jar
*.pid
Gemfile.lock
-solr/data/
-.sass-cache/
+solr/data/*
+.sass-cache/
View
10 app/assets/stylesheets/admin.css.scss
@@ -38,7 +38,17 @@ body {
color: white;
}
}
+ ul.dropdown-menu{
+ a {
+ color: #555;
+ &:hover {
+ color: black;
+ }
+ }
+ }
}
+
+
}
}
View
67 app/controllers/admin/departments_controller.rb
@@ -0,0 +1,67 @@
+# encoding: utf-8 rails
+
+class Admin::DepartmentsController < Admin::ApplicationController
+ load_and_authorize_resource :only => [:show, :new, :destroy, :edit, :update]
+ rescue_from ActiveRecord::RecordNotFound do |exception|
+ redirect_to admin_departments_path, :alert => "There is no Department with ID=#{params[:id]}."
+ end
+
+ def index
+ @departments = Department.order(:name).page(params[:page])
+ end
+
+
+ def show
+ end
+
+
+ def new
+ # @department = Department.new
+ end
+
+
+ def edit
+ @department = Department.find(params[:id])
+ end
+
+
+ def create
+ @department = Department.new(params[:department])
+
+ respond_to do |format|
+ if @department.save
+ format.html { redirect_to [:admin, @department], notice: 'Department was successfully created.' }
+ format.json { render json: @department, status: :created, location: @department }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @department.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+
+ def update
+ @department = Department.find(params[:id])
+
+ respond_to do |format|
+ if @department.update_attributes(params[:department])
+ format.html { redirect_to [:admin, @department], notice: 'Department was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @department.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+
+ def destroy
+ @department = Department.find(params[:id])
+ @department.destroy
+
+ respond_to do |format|
+ format.html { redirect_to admin_departments_url }
+ format.json { head :no_content }
+ end
+ end
+end
View
2 app/controllers/admin/users_controller.rb
@@ -8,7 +8,7 @@ class Admin::UsersController < Admin::ApplicationController
# GET /users.json HTML and AJAX
#-----------------------------------------------------------------------
def index
- @users = User.accessible_by(current_ability, :index).order(:id).page(params[:page])
+ @users = User.accessible_by(current_ability, :index).order(:first_name,:last_name).page(params[:page])
end
# GET /users/new
View
2 app/helpers/departments_helper.rb
@@ -0,0 +1,2 @@
+module DepartmentsHelper
+end
View
4 app/models/department.rb
@@ -0,0 +1,4 @@
+class Department < ActiveRecord::Base
+ has_many :users
+ validates :name, :presence => true
+end
View
1 app/models/user.rb
@@ -9,6 +9,7 @@ class User < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name
has_and_belongs_to_many :roles, :uniq => true
+ belongs_to :department
def role?(role)
return !!self.roles.find_by_name(role.to_s.camelize)
View
9 app/views/admin/departments/_department_fields.html.haml
@@ -0,0 +1,9 @@
+= simple_form_for ['admin', @department] do |f|
+ = display_actions f, admin_departments_url
+ %hr.soften
+ = display_errors f
+
+ = f.input :name
+
+ %hr.soften
+ = display_actions f, admin_departments_url
View
8 app/views/admin/departments/edit.html.haml
@@ -0,0 +1,8 @@
+%header.subhead#overview
+ %h2 Edit Department
+ .subnav
+ %ul.nav.nav-pills
+ %li= link_to "Show", [:admin, @department]
+ %li= link_to "View All", admin_departments_path
+
+ = render 'department_fields'
View
29 app/views/admin/departments/index.html.haml
@@ -0,0 +1,29 @@
+%header.subhead#overview
+ %h2 Departments
+ %p
+ = link_to_if can?(:create, Department), "New Department", new_admin_department_path, :class => 'btn btn-success btn-large pull-right' do
+ .unable New Department
+
+%section
+ = paginate @departments
+
+ %table.table.table-striped.table-bordered.table-condensed
+ %thead
+ %tr
+ %th ID
+ %th Name
+ %tbody
+ - @departments.each do |d|
+ %tr(class="#{cycle('odd', 'even')}")
+ %td= d.id
+ %td= d.name
+ %td
+ = link_to_if can?(:show, d), "Show", admin_department_path(d.id) do
+ %span.unable Show
+ %td
+ = link_to_if can?(:update, d), 'Edit', edit_admin_department_path(d) do
+ %span.unable Edit
+ %td
+ = link_to_if can?(:delete, d), 'Destroy', admin_department_path(d), :confirm => 'Are you sure?', :method => :delete do
+ %span.unable Destroy
+
View
4 app/views/admin/departments/new.html.haml
@@ -0,0 +1,4 @@
+%header.subhead#overview
+ %h2 Register Department
+
+ = render 'department_fields'
View
13 app/views/admin/departments/show.html.haml
@@ -0,0 +1,13 @@
+%header.subhead#overview
+ %h2 Department
+ .subnav
+ %ul.nav.nav-pills
+ %li
+ = link_to_if can?(:update, @department), "Edit", edit_admin_department_path(@department) do
+ %a.unable Edit
+ %li
+ = link_to_if can?(:destroy, @department), "Destroy", admin_department_path(@department), :class => 'label label-important', :confirm => 'Are you sure?', :method => :delete do
+ %a.unable Destroy
+
+%section.well
+ = display_show_item('Name', @department.name)
View
4 app/views/admin/users/_user_fields.html.haml
@@ -3,4 +3,6 @@
= f.input :email
- if can? :read, Role
- = f.association :roles
+ = f.association :roles
+- if can? :read, Department
+ = f.association :department
View
2 app/views/admin/users/index.html.haml
@@ -14,6 +14,7 @@
%th Name
%th Email
%th Roles
+ %th Department
%th(colspan=3) Actions
- if current_user.role?(:super_admin)
%th Become
@@ -24,6 +25,7 @@
%td= "#{u.first_name} #{u.last_name}"
%td= u.email
%td.small= u.roles.collect{|r| r.name}.join(', ')
+ %td= u.department.try(:name)
%td
= link_to_if can?(:show, u), "Show", admin_user_path(u.id) do
%span.unable Show
View
1 app/views/admin/users/show.html.haml
@@ -14,6 +14,7 @@
= display_show_item('Name', "#{@user.first_name} #{@user.last_name}")
= display_show_item('Email', @user.email)
= display_show_item('Roles', @user.roles.collect{|r| r.name}.join(', '))
+ = display_show_item('Department', @user.department.try(:name))
= display_show_item('Created At', @user.created_at.to_s(:long_ordinal))
= display_show_item('Last Sign In', @user.last_sign_in_at.blank? ? 'Never' : @user.last_sign_in_at.to_s(:long_ordinal))
= display_show_item('Sign In Count', @user.sign_in_count)
View
14 app/views/layouts/_admin_navigation.html.haml
@@ -23,6 +23,14 @@
%li
= link_to_if can?(:update, Catalog), 'Catalogs', admin_catalogs_path do
.unable Catalogs
- %li
- = link_to_if can?(:update, Catalog), 'Containers\' patterns', admin_lessondesc_patterns_path do
- .unable Containers' patterns
+ %li.dropdown
+ %a.dropdown-toggle{:href => "#", :"data-toggle" => "dropdown"}
+ Other
+ %b.a
+ %ul.dropdown-menu
+ = link_to_if can?(:update, Catalog), "Containers' patterns", admin_lessondesc_patterns_path do
+ .unable Containers' patterns
+ = link_to_if can?(:update, Department), 'Departments', admin_departments_path do
+ .unable Departments
+
+
View
1 config/routes.rb
@@ -22,6 +22,7 @@
end
resources :file_assets
resources :catalogs
+ resources :departments
resources :users do
member do
get :become
View
9 db/migrate/20120224182559_create_departments.rb
@@ -0,0 +1,9 @@
+# encoding: UTF-8
+class CreateDepartments < ActiveRecord::Migration
+ def change
+ create_table :departments do |t|
+ t.string :name
+ t.timestamps
+ end
+ end
+end
View
5 db/migrate/20120225083015_add_department_id_to_users.rb
@@ -0,0 +1,5 @@
+class AddDepartmentIdToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :department_id, :integer
+ end
+end
View
2 db/migrate/20120226090927_add_devise_token_auth_columns.rb
@@ -7,6 +7,6 @@ def self.up
end
def self.down
- t.remove :authentication_token
+ remove_column :users,:authentication_token
end
end
View
50 db/schema.rb
@@ -1,3 +1,4 @@
+# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
@@ -10,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110907140500) do
+ActiveRecord::Schema.define(:version => 20120304101228) do
create_table "answers", :id => false, :force => true do |t|
t.timestamp "datetime", :null => false
@@ -48,13 +49,12 @@
add_index "booksdesc", ["fileid"], :name => "fileid"
create_table "catalognode", :primary_key => "catalognodeid", :force => true do |t|
- t.string "catalognodename", :limit => 100, :default => "", :null => false
+ t.string "catalognodename", :limit => 100, :default => "", :null => false
t.integer "parentnodeid"
t.datetime "created"
t.datetime "updated"
- t.integer "catorder", :default => 999, :null => false
- t.integer "secure", :default => 0, :null => false
- t.boolean "delta", :default => true, :null => false
+ t.integer "catorder", :default => 999, :null => false
+ t.integer "secure", :default => 0, :null => false
end
add_index "catalognode", ["catalognodename", "parentnodeid"], :name => "cnnamepid", :unique => true
@@ -78,6 +78,18 @@
add_index "catnodelessons", ["lessonid"], :name => "index_catnodelessons_on_lessonid"
+ create_table "content_types", :force => true do |t|
+ t.string "name"
+ t.string "pattern"
+ t.integer "secure", :default => 0
+ end
+
+ create_table "departments", :force => true do |t|
+ t.string "name"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "filedesc", :primary_key => "filedescid", :force => true do |t|
t.integer "fileid", :default => 0, :null => false
t.string "filedesc"
@@ -101,7 +113,7 @@
t.datetime "updated"
t.string "lastuser", :limit => 7
t.integer "fileclicks", :default => 0
- t.boolean "delta", :default => true, :null => false
+ t.integer "secure", :default => 0
end
add_index "files", ["filename"], :name => "filename", :unique => true
@@ -137,7 +149,7 @@
add_index "lecturerdesc", ["lecturerid", "lang"], :name => "lecturerid", :unique => true
create_table "lessondesc", :primary_key => "lessondescid", :force => true do |t|
- t.integer "lessonid", :default => 0, :null => false
+ t.integer "lessonid", :default => 0, :null => false
t.string "lessondesc"
t.string "lang", :limit => 3
t.datetime "created"
@@ -145,7 +157,6 @@
t.text "descr"
t.string "lessondesc_flat"
t.text "descr_flat"
- t.boolean "delta", :default => true, :null => false
end
add_index "lessondesc", ["lessondesc", "descr"], :name => "lessondesc"
@@ -158,7 +169,6 @@
t.string "lang"
t.datetime "created_at"
t.datetime "updated_at"
- t.boolean "delta", :default => true, :null => false
end
create_table "lessonfiles", :id => false, :force => true do |t|
@@ -167,14 +177,15 @@
end
create_table "lessons", :primary_key => "lessonid", :force => true do |t|
- t.string "lessonname", :limit => 100
+ t.string "lessonname", :limit => 100
t.datetime "created"
t.datetime "updated"
t.date "lessondate"
- t.string "lang", :limit => 3
+ t.string "lang", :limit => 3
t.integer "lecturerid"
- t.integer "secure", :default => 0, :null => false
- t.boolean "delta", :default => true, :null => false
+ t.integer "secure", :default => 0, :null => false
+ t.integer "content_type_id"
+ t.boolean "marked_for_merge"
end
add_index "lessons", ["lang"], :name => "lessonlangidx"
@@ -278,19 +289,22 @@
end
create_table "users", :force => true do |t|
- t.string "email", :default => "", :null => false
- t.string "encrypted_password", :limit => 128, :default => "", :null => false
+ t.string "email", :default => "", :null => false
+ t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "reset_password_token"
t.datetime "remember_created_at"
- t.integer "sign_in_count", :default => 0
+ t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "first_name", :default => ""
- t.string "last_name", :default => ""
+ t.string "first_name", :default => ""
+ t.string "last_name", :default => ""
+ t.integer "department_id"
+ t.string "authentication_token"
+ t.datetime "reset_password_sent_at"
end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
View
12 db/seeds.rb
@@ -73,4 +73,16 @@
{:name => 'Magazine', :pattern => 'magazine'},
].each{|r| ContentType.find_or_create_by_pattern(r)}
+
+puts '--> Departments'
+[
+ {:name => 'צוות שיעור בוקר'},
+ {:name => 'קבלה מדיה רוסית'},
+ {:name => 'קבלה מדיה עברית'},
+ {:name => 'מילות מפתח עברית'},
+ {:name => 'מילות מפתח רוסית'},
+ {:name => 'תיאורים נוספים'},
+].each { |r| Department.find_or_create_by_name(r) }
+
+
puts '--> Done'
View
9 test/fixtures/departments.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ name: MyString
+ has_many:
+
+two:
+ name: MyString
+ has_many:
View
49 test/functional/departments_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class DepartmentsControllerTest < ActionController::TestCase
+ setup do
+ @department = departments(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:departments)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create department" do
+ assert_difference('Department.count') do
+ post :create, department: @department.attributes
+ end
+
+ assert_redirected_to department_path(assigns(:department))
+ end
+
+ test "should show department" do
+ get :show, id: @department
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @department
+ assert_response :success
+ end
+
+ test "should update department" do
+ put :update, id: @department, department: @department.attributes
+ assert_redirected_to department_path(assigns(:department))
+ end
+
+ test "should destroy department" do
+ assert_difference('Department.count', -1) do
+ delete :destroy, id: @department
+ end
+
+ assert_redirected_to departments_path
+ end
+end
View
7 test/unit/department_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class DepartmentTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
View
4 test/unit/helpers/departments_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class DepartmentsHelperTest < ActionView::TestCase
+end
Something went wrong with that request. Please try again.