Groups are now workgroups. First part of moving groups-logic into admin-namespace.
This commit is contained in:
parent
461dfa8531
commit
2d5dc03b90
31 changed files with 616 additions and 37 deletions
35
app/controllers/admin/memberships_controller.rb
Normal file
35
app/controllers/admin/memberships_controller.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
class Admin::MembershipsController < ApplicationController
|
||||
|
||||
def add_member
|
||||
@group = Group.find(params[:group_id])
|
||||
user = User.find(params[:user_id])
|
||||
Membership.create(:group => @group, :user => user)
|
||||
redirect_to :action => 'reload', :group_id => @group
|
||||
end
|
||||
|
||||
def drop_member
|
||||
begin
|
||||
group = Group.find(params[:group_id])
|
||||
Membership.find(params[:membership_id]).destroy
|
||||
if User.find(@current_user.id).role_admin?
|
||||
redirect_to :action => 'reload', :group_id => group
|
||||
else
|
||||
# If the user drops himself from admin group
|
||||
flash[:notice] = MESG_NO_ADMIN_ANYMORE
|
||||
render(:update) {|page| page.redirect_to :controller => "index"}
|
||||
end
|
||||
rescue => error
|
||||
flash[:error] = error.to_s
|
||||
redirect_to :action => 'reload', :group_id => group
|
||||
end
|
||||
end
|
||||
|
||||
def reload
|
||||
@group = Group.find(params[:group_id])
|
||||
render :update do |page|
|
||||
page.replace_html 'members', :partial => 'members', :object => @group
|
||||
page.replace_html 'non_members', :partial => 'non_members', :object => @group
|
||||
end
|
||||
end
|
||||
|
||||
end
|
67
app/controllers/admin/workgroups_controller.rb
Normal file
67
app/controllers/admin/workgroups_controller.rb
Normal file
|
@ -0,0 +1,67 @@
|
|||
class Admin::WorkgroupsController < ApplicationController
|
||||
|
||||
def index
|
||||
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
|
||||
@per_page = params[:per_page].to_i
|
||||
else
|
||||
@per_page = 20
|
||||
end
|
||||
|
||||
# if the search field is used
|
||||
conditions = "name LIKE '%#{params[:query]}%'" unless params[:query].nil?
|
||||
|
||||
@workgroups = Workgroup.paginate(:conditions => conditions, :page => params[:page],
|
||||
:per_page => @per_page, :order => 'name')
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.js { render :partial => "workgroups" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
@workgroup = Workgroup.find(params[:id])
|
||||
end
|
||||
|
||||
def new
|
||||
@workgroup = Workgroup.new
|
||||
end
|
||||
|
||||
def edit
|
||||
@workgroup = Workgroup.find(params[:id])
|
||||
end
|
||||
|
||||
def create
|
||||
@workgroup = Workgroup.new(params[:workgroup])
|
||||
|
||||
if @workgroup.save
|
||||
flash[:notice] = 'Workgroup was successfully created.'
|
||||
redirect_to([:admin, @workgroup])
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@workgroup = Workgroup.find(params[:id])
|
||||
|
||||
if @workgroup.update_attributes(params[:workgroup])
|
||||
flash[:notice] = 'Workgroup was successfully updated.'
|
||||
redirect_to([:admin, @workgroup])
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@workgroup = Workgroup.find(params[:id])
|
||||
@workgroup.destroy
|
||||
|
||||
redirect_to(admin_workgroups_url)
|
||||
end
|
||||
|
||||
def memberships
|
||||
@group = Workgroup.find(params[:id])
|
||||
end
|
||||
end
|
2
app/helpers/admin/memberships_helper.rb
Normal file
2
app/helpers/admin/memberships_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
module Admin::MembershipsHelper
|
||||
end
|
|
@ -1,3 +1,28 @@
|
|||
# == Schema Information
|
||||
# Schema version: 20090113111624
|
||||
#
|
||||
# Table name: articles
|
||||
#
|
||||
# id :integer(4) not null, primary key
|
||||
# name :string(255) default(""), not null
|
||||
# supplier_id :integer(4) default(0), not null
|
||||
# article_category_id :integer(4) default(0), not null
|
||||
# unit :string(255) default(""), not null
|
||||
# note :string(255)
|
||||
# availability :boolean(1) default(TRUE), not null
|
||||
# manufacturer :string(255)
|
||||
# origin :string(255)
|
||||
# shared_updated_on :datetime
|
||||
# net_price :decimal(8, 2)
|
||||
# gross_price :decimal(8, 2) default(0.0), not null
|
||||
# tax :float
|
||||
# deposit :decimal(8, 2) default(0.0)
|
||||
# unit_quantity :integer(4) default(1), not null
|
||||
# order_number :string(255)
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
#
|
||||
|
||||
# == Schema Information
|
||||
# Schema version: 20090102171850
|
||||
#
|
||||
|
|
|
@ -28,12 +28,6 @@
|
|||
class Group < ActiveRecord::Base
|
||||
has_many :memberships, :dependent => :destroy
|
||||
has_many :users, :through => :memberships
|
||||
has_many :tasks
|
||||
# returns all non-finished tasks
|
||||
has_many :open_tasks, :class_name => 'Task', :conditions => ['done = ?', false], :order => 'due_date ASC'
|
||||
|
||||
attr_accessible :name, :description, :role_admin, :role_suppliers, :role_article_meta, :role_finance, :role_orders,
|
||||
:weekly_task, :weekday, :task_name, :task_description, :task_required_users
|
||||
|
||||
validates_length_of :name, :in => 1..25
|
||||
validates_uniqueness_of :name
|
||||
|
@ -63,31 +57,9 @@ class Group < ActiveRecord::Base
|
|||
raise ERR_LAST_ADMIN_GROUP_DELETE if self.role_admin == true && Group.find_all_by_role_admin(true).size == 1
|
||||
end
|
||||
|
||||
# Returns an Array with date-objects to represent the next weekly-tasks
|
||||
def next_weekly_tasks(number = 8)
|
||||
# our system starts from 0 (sunday) to 6 (saturday)
|
||||
# get difference between groups weekday and now
|
||||
diff = self.weekday - Time.now.wday
|
||||
if diff >= 0
|
||||
# weektask is in current week
|
||||
nextTask = diff.day.from_now
|
||||
else
|
||||
# weektask is in the next week
|
||||
nextTask = (diff + 7).day.from_now
|
||||
end
|
||||
# now generate the Array
|
||||
nextTasks = Array.new
|
||||
number.times do
|
||||
nextTasks << nextTask
|
||||
nextTask = 1.week.from_now(nextTask)
|
||||
end
|
||||
return nextTasks
|
||||
end
|
||||
|
||||
# get all groups, which are NOT OrderGroups
|
||||
#TODO: better implement a new model, which inherits from Group, e.g. WorkGroup
|
||||
def self.workgroups
|
||||
Group.find :all, :conditions => "type IS NULL"
|
||||
Workgroup.all
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# == Schema Information
|
||||
# Schema version: 20090102171850
|
||||
# Schema version: 20090113111624
|
||||
#
|
||||
# Table name: invoices
|
||||
#
|
||||
|
@ -9,6 +9,7 @@
|
|||
# number :string(255)
|
||||
# date :date
|
||||
# paid_on :date
|
||||
# note :text
|
||||
# amount :decimal(8, 2) default(0.0), not null
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
|
|
|
@ -72,8 +72,10 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def update_settings
|
||||
for setting in User::setting_keys.keys
|
||||
self.settings[setting] = setting_attributes[setting] && setting_attributes[setting] == '1' ? '1' : nil
|
||||
unless setting_attributes.nil?
|
||||
for setting in User::setting_keys.keys
|
||||
self.settings[setting] = setting_attributes[setting] && setting_attributes[setting] == '1' ? '1' : nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
57
app/models/workgroup.rb
Normal file
57
app/models/workgroup.rb
Normal file
|
@ -0,0 +1,57 @@
|
|||
# == Schema Information
|
||||
# Schema version: 20090113111624
|
||||
#
|
||||
# Table name: groups
|
||||
#
|
||||
# id :integer(4) not null, primary key
|
||||
# type :string(255) default(""), not null
|
||||
# name :string(255) default(""), not null
|
||||
# description :string(255)
|
||||
# actual_size :integer(4)
|
||||
# account_balance :decimal(8, 2) default(0.0), not null
|
||||
# account_updated :datetime
|
||||
# created_on :datetime not null
|
||||
# role_admin :boolean(1) not null
|
||||
# role_suppliers :boolean(1) not null
|
||||
# role_article_meta :boolean(1) not null
|
||||
# role_finance :boolean(1) not null
|
||||
# role_orders :boolean(1) not null
|
||||
# weekly_task :boolean(1)
|
||||
# weekday :integer(4)
|
||||
# task_name :string(255)
|
||||
# task_description :string(255)
|
||||
# task_required_users :integer(4) default(1)
|
||||
#
|
||||
|
||||
class Workgroup < Group
|
||||
|
||||
has_many :tasks
|
||||
# returns all non-finished tasks
|
||||
has_many :open_tasks, :class_name => 'Task', :conditions => ['done = ?', false], :order => 'due_date ASC'
|
||||
|
||||
def self.weekdays
|
||||
[["Montag", "1"], ["Dienstag", "2"], ["Mittwoch","3"],["Donnerstag","4"],["Freitag","5"],["Samstag","6"],["Sonntag","0"]]
|
||||
end
|
||||
|
||||
# Returns an Array with date-objects to represent the next weekly-tasks
|
||||
def next_weekly_tasks(number = 8)
|
||||
# our system starts from 0 (sunday) to 6 (saturday)
|
||||
# get difference between groups weekday and now
|
||||
diff = self.weekday - Time.now.wday
|
||||
if diff >= 0
|
||||
# weektask is in current week
|
||||
nextTask = diff.day.from_now
|
||||
else
|
||||
# weektask is in the next week
|
||||
nextTask = (diff + 7).day.from_now
|
||||
end
|
||||
# now generate the Array
|
||||
nextTasks = Array.new
|
||||
number.times do
|
||||
nextTasks << nextTask
|
||||
nextTask = 1.week.from_now(nextTask)
|
||||
end
|
||||
return nextTasks
|
||||
end
|
||||
|
||||
end
|
21
app/views/admin/memberships/_edit_members.rhtml
Normal file
21
app/views/admin/memberships/_edit_members.rhtml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<h1>Mitglieder von <%=h @group.name %></h1>
|
||||
<p>
|
||||
<i>Hier kannst Du die Mitglieder der Gruppe verwalten.</i>
|
||||
</p>
|
||||
<div class="left_column" style="width:48%">
|
||||
<div class="box_title">
|
||||
<h2>Sind schon Mitglieder</h2>
|
||||
</div>
|
||||
<div class="column_content" id="members">
|
||||
<%=render :partial => 'admin/memberships/members' %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right_column" style="width:48%">
|
||||
<div class="box_title">
|
||||
<h2>Sind noch keine Mitglieder</h2>
|
||||
</div>
|
||||
<div class="column_content" id="non_members">
|
||||
<%= render :partial => 'admin/memberships/non_members' %>
|
||||
<%= link_to('Person einladen', :controller =>'index', :action => 'invite', :id => @group) if (@current_user.is_member_of(@group) || @current_user.role_admin?) %>
|
||||
</div>
|
||||
</div>
|
21
app/views/admin/memberships/_members.rhtml
Normal file
21
app/views/admin/memberships/_members.rhtml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<% if flash[:error] %>
|
||||
<h3 class="error" id="flashError" ><%= flash[:error] %></h3>
|
||||
<%= javascript_tag("new Effect.Highlight('flashError', {delay:0.8, duration:1});") -%>
|
||||
<% end %>
|
||||
|
||||
<% memberships = @group.memberships
|
||||
if memberships.size != 0 %>
|
||||
<ul style="">
|
||||
<% for membership in memberships %>
|
||||
<li style="margin-left:-15px">
|
||||
<b><%= membership.user.nick %></b> (<%=h membership.user.first_name + ' ' + membership.user.last_name %>)
|
||||
| <%= link_to_remote 'entfernen',
|
||||
:url => { :controller => 'admin/memberships', :action => 'drop_member', :group_id => @group, :membership_id => membership },
|
||||
:before => "Element.show('loader')",
|
||||
:success => "Element.hide('loader')" %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<p><i><%= @group.name %> hat keine Mitglieder.</i></p>
|
||||
<% end %>
|
11
app/views/admin/memberships/_non_members.rhtml
Normal file
11
app/views/admin/memberships/_non_members.rhtml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<ul>
|
||||
<% for user in @group.non_members %>
|
||||
<li>
|
||||
<b><%= user.nick %></b> (<%=h user.first_name + ' ' + user.last_name %>)
|
||||
| <%= link_to_remote 'hinzufügen',
|
||||
:url => { :controller => 'admin/memberships', :action => 'add_member', :group_id => @group, :user_id => user },
|
||||
:before => "Element.show('loader')",
|
||||
:success => "Element.hide('loader')" %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
84
app/views/admin/workgroups/_form.html.haml
Normal file
84
app/views/admin/workgroups/_form.html.haml
Normal file
|
@ -0,0 +1,84 @@
|
|||
- form_for [:admin, @workgroup] do |@form|
|
||||
= @form.error_messages
|
||||
|
||||
%div{:style => "float:left;width:55%;"}
|
||||
%p
|
||||
= @form.label :name
|
||||
%br/
|
||||
= @form.text_field :name, :size => 20
|
||||
%p
|
||||
= @form.label :description
|
||||
%br/
|
||||
= @form.text_field :description, :size => 40
|
||||
|
||||
%div{:style => "float:right;width:40%"}
|
||||
%h3 Gruppe hat Zugriff auf
|
||||
%table
|
||||
%tr
|
||||
%td
|
||||
= @form.label :role_admin, "Administration"
|
||||
%td= @form.check_box :role_admin
|
||||
%tr
|
||||
%td
|
||||
= @form.label :role_finance, "Finanzen"
|
||||
%td= @form.check_box :role_finance
|
||||
%tr
|
||||
%td
|
||||
= @form.label :role_suppliers, "Lieferantenverwaltung"
|
||||
%td= @form.check_box :role_suppliers
|
||||
%tr
|
||||
%td
|
||||
= @form.label :role_article_meta, "Artikelverwaltung"
|
||||
%td= @form.check_box :role_article_meta
|
||||
%tr
|
||||
%td
|
||||
= @form.label :role_orders, "Bestellungsverwaltung"
|
||||
%td= @form.check_box :role_orders
|
||||
|
||||
%div{:style => "clear:both"}
|
||||
%h3
|
||||
Wöchentliche Jobs definieren?
|
||||
= @form.check_box :weekly_task, {:onclick => "toggleWeeklyTask();"}
|
||||
%table
|
||||
%tr
|
||||
%td
|
||||
= @form.label :weekday, "Wochentag:"
|
||||
%td
|
||||
= @form.select :weekday, Workgroup.weekdays
|
||||
%tr
|
||||
%td
|
||||
= @form.label :task_name, "Dienstname:"
|
||||
%td= @form.text_field :task_name, :size => 20
|
||||
%tr
|
||||
%td
|
||||
= @form.label :task_required_users, "Benötigte Verantwortliche:"
|
||||
%td= @form.text_field :task_required_users, :size => 3
|
||||
%tr
|
||||
%td
|
||||
= @form.label :task_description, "Beschreibung:"
|
||||
%td= @form.text_area :task_description
|
||||
|
||||
%br{ :style => "clear:both" }
|
||||
= submit_tag "Speichern"
|
||||
|
|
||||
= link_to "Abbrechen", admin_workgroups_path
|
||||
|
||||
%script{ 'type' => "text/javascript"}
|
||||
:plain
|
||||
//<![CDATA[
|
||||
// preset data
|
||||
function toggleWeeklyTask(){
|
||||
if ($("workgroup_weekly_task").checked == true) {
|
||||
$('workgroup_weekday').disabled = false;
|
||||
$('workgroup_task_name').disabled = false;
|
||||
$('workgroup_task_required_users').disabled = false;
|
||||
$('workgroup_task_description').disabled = false;
|
||||
} else {
|
||||
$('workgroup_weekday').disabled = true;
|
||||
$('workgroup_task_name').disabled = true;
|
||||
$('workgroup_task_required_users').disabled = true;
|
||||
$('workgroup_task_description').disabled = true;
|
||||
}
|
||||
}
|
||||
toggleWeeklyTask();
|
||||
//]]>
|
24
app/views/admin/workgroups/_workgroups.html.haml
Normal file
24
app/views/admin/workgroups/_workgroups.html.haml
Normal file
|
@ -0,0 +1,24 @@
|
|||
%p
|
||||
%table{:style => "width:100%"}
|
||||
%tr
|
||||
%td
|
||||
= pagination_links_remote @workgroups
|
||||
%td{:style => "text-align:right"}
|
||||
- if @workgroups.size > 20
|
||||
= items_per_page
|
||||
%table.list
|
||||
%thead
|
||||
%tr
|
||||
%th Name
|
||||
%th Mitglieder
|
||||
%th
|
||||
%tbody
|
||||
- for workgroup in @workgroups
|
||||
%tr{:class => cycle('even','odd', :name => 'groups')}
|
||||
%td= link_to workgroup.name, [:admin, workgroup]
|
||||
%td= workgroup.users.size
|
||||
%td
|
||||
= link_to image_tag('b_users.png', :size => '16x16', :border => "0", :alt => 'Mitlglieder bearbeiten'), memberships_admin_workgroup_path(workgroup)
|
||||
= link_to(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => 'Gruppe bearbeiten'), edit_admin_workgroup_path(workgroup))
|
||||
= link_to(image_tag('b_drop.png', :size => "16x16", :border => "0", :alt => 'Gruppe löschen'), [:admin, workgroup], |
|
||||
:confirm => 'Willst du ' + workgroup.name + ' wirklich löschen?', :method => :delete) |
|
4
app/views/admin/workgroups/edit.html.haml
Normal file
4
app/views/admin/workgroups/edit.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
- title "Arbeitsgruppe bearbeiten"
|
||||
|
||||
.edit_form{:style => "width:50em"}
|
||||
= render :partial => 'form'
|
34
app/views/admin/workgroups/index.html.haml
Normal file
34
app/views/admin/workgroups/index.html.haml
Normal file
|
@ -0,0 +1,34 @@
|
|||
- title "List workgroups"
|
||||
|
||||
%p
|
||||
%i
|
||||
Hier kannst du
|
||||
= link_to 'neue Arbeitsgruppen', new_admin_workgroup_path
|
||||
anlegen, Gruppen bearbeiten und löschen.
|
||||
|
||||
%p
|
||||
Beachte dabei den <em>Unterschied zwischen Gruppe und Bestellgruppe</em>:
|
||||
Eine
|
||||
%em= link_to 'Bestellgruppe', '/admin/ordergroups'
|
||||
hat ein Konto und kann Essen bestellen. In einer Arbeitsgruppe (z.b. 'Soritiergruppe')
|
||||
koordinieren sich die Mitglieder mittels Aufgaben und Nachrichten.
|
||||
Nutzer_innen können immer nur einer Bestellgruppe, aber beliebig vielen anderen Gruppen angehören.
|
||||
.left_column{:style => "width:100%"}
|
||||
.box_title
|
||||
%h2 Gruppenübersicht
|
||||
.column_content
|
||||
#group_filter
|
||||
%form{:name=>"sform", :action=>"", :style=>"display:inline;"}
|
||||
%label{:for => 'workgroup_name'} Suche in Name :
|
||||
= text_field_tag("query", params['query'], :size => 10 )
|
||||
|
||||
= observe_field 'query', :frequency => 2, |
|
||||
:before => "Element.show('loader')", |
|
||||
:success => "Element.hide('loader')", |
|
||||
:update => "workgroups", |
|
||||
:url => admin_workgroups_path, |
|
||||
:with => 'query', |
|
||||
:method => :get |
|
||||
#workgroups
|
||||
= render :partial => "workgroups"
|
||||
= link_to 'Neue Arbeits', new_admin_workgroup_path
|
3
app/views/admin/workgroups/memberships.html.haml
Normal file
3
app/views/admin/workgroups/memberships.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
= render :partial => 'admin/memberships/edit_members'
|
||||
%p{ :style => "clear:both" }
|
||||
= link_to 'Gruppenübersicht', admin_workgroups_path
|
4
app/views/admin/workgroups/new.html.haml
Normal file
4
app/views/admin/workgroups/new.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
- title "Erstelle Arbeitsgruppe"
|
||||
|
||||
.edit_form{:style => "width:50em"}
|
||||
= render :partial => 'form'
|
42
app/views/admin/workgroups/show.html.haml
Normal file
42
app/views/admin/workgroups/show.html.haml
Normal file
|
@ -0,0 +1,42 @@
|
|||
- title "Arbeitsgruppe #{@workgroup.name}"
|
||||
.left_column{:style => "width:45em"}
|
||||
.box_title
|
||||
%h2 Übersicht
|
||||
.column_content
|
||||
%p
|
||||
%b Beschreibung:
|
||||
=h @workgroup.description
|
||||
%p
|
||||
%b Gruppe hat Zugriff auf:
|
||||
- roles = Array.new
|
||||
- roles << 'Administration' if @workgroup.role_admin?
|
||||
- roles << 'Finanzen' if @workgroup.role_finance?
|
||||
- roles << 'Lieferanten' if @workgroup.role_suppliers?
|
||||
- roles << 'Artikel' if @workgroup.role_article_meta?
|
||||
- roles << 'Bestellungsverwaltung' if @workgroup.role_orders?
|
||||
=h roles.join(', ')
|
||||
%p
|
||||
- if @workgroup.weekly_task
|
||||
%b wöchentlicher Job:
|
||||
=h @workgroup.task_name
|
||||
am
|
||||
= weekday(@workgroup.weekday)
|
||||
- else
|
||||
kein wöchentlicher Job definiert
|
||||
|
||||
= link_to 'Gruppe bearbeiten', edit_admin_workgroup_path(@workgroup)
|
||||
|
|
||||
= link_to 'Löschen', [:admin, @workgroup], :confirm => 'Bist Du sicher?', :method => :delete
|
||||
|
|
||||
= link_to 'Nachricht senden', :controller => 'messages', :action => 'group', :id => @workgroup
|
||||
.box_title
|
||||
%h2 Mitglieder
|
||||
.column_content
|
||||
- if @workgroup.memberships.empty?
|
||||
%i Diese Gruppe hat derzeit keine Mitglieder
|
||||
- else
|
||||
%ul{:style => "list-style-type:decimal;"}
|
||||
- for membership in @workgroup.memberships
|
||||
%li= link_to membership.user.nick, [:admin, membership.user]
|
||||
%p= link_to 'Mitglieder bearbeiten', memberships_admin_workgroup_path(@workgroup)
|
||||
%p{:style => "clear:both"}= link_to "Gruppenübersicht", admin_workgroups_path
|
|
@ -36,11 +36,11 @@
|
|||
]
|
||||
},
|
||||
{ :name => "Administration", :url => "/admin",
|
||||
:active => ["admin", "admin/users"],
|
||||
:active => ["admin", "admin/users", "admin/workgroups"],
|
||||
:access? => (u.role_admin?),
|
||||
:subnav => [
|
||||
{ :name => "Users", :url => "/admin/users" },
|
||||
{ :name => "Groups", :url => "/admin/listGroups" }
|
||||
{ :name => "Workgroups", :url => "/admin/workgroups" }
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
17
app/views/layouts/workgroups.html.erb
Normal file
17
app/views/layouts/workgroups.html.erb
Normal file
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
||||
<title>Workgroups: <%= controller.action_name %></title>
|
||||
<%= stylesheet_link_tag 'scaffold' %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p style="color: green"><%= flash[:notice] %></p>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -2,6 +2,9 @@ ActionController::Routing::Routes.draw do |map|
|
|||
|
||||
map.namespace :admin do |admin|
|
||||
admin.resources :users
|
||||
admin.resources :workgroups, :member => { :memberships => :get }
|
||||
admin.connect 'memberships/:action/:id', :controller => 'memberships'
|
||||
admin.add_member 'add_member', :controller => 'memberships', :action => 'add_member'
|
||||
end
|
||||
|
||||
map.namespace :finance do |finance|
|
||||
|
|
14
db/migrate/20090113111624_create_workgroups.rb
Normal file
14
db/migrate/20090113111624_create_workgroups.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
class CreateWorkgroups < ActiveRecord::Migration
|
||||
def self.up
|
||||
# Migrate all groups to workgroups
|
||||
Group.find(:all, :conditions => { :type => "" }).each do |workgroup|
|
||||
workgroup.update_attribute(:type, "Workgroup")
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
Group.find(:all, :conditions => { :type => "Workgroup" }).each do |workgroup|
|
||||
workgroup.update_attribute(:type, "")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -9,7 +9,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20090102155714) do
|
||||
ActiveRecord::Schema.define(:version => 20090113111624) do
|
||||
|
||||
create_table "article_categories", :force => true do |t|
|
||||
t.string "name", :default => "", :null => false
|
||||
|
@ -71,6 +71,12 @@ ActiveRecord::Schema.define(:version => 20090102155714) do
|
|||
|
||||
add_index "configurable_settings", ["name"], :name => "index_configurable_settings_on_name"
|
||||
|
||||
create_table "deliveries", :force => true do |t|
|
||||
t.integer "supplier_id"
|
||||
t.date "delivered_on"
|
||||
t.datetime "created_at"
|
||||
end
|
||||
|
||||
create_table "financial_transactions", :force => true do |t|
|
||||
t.integer "order_group_id", :default => 0, :null => false
|
||||
t.decimal "amount", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
|
|
54
public/stylesheets/scaffold.css
Normal file
54
public/stylesheets/scaffold.css
Normal file
|
@ -0,0 +1,54 @@
|
|||
body { background-color: #fff; color: #333; }
|
||||
|
||||
body, p, ol, ul, td {
|
||||
font-family: verdana, arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #eee;
|
||||
padding: 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
a { color: #000; }
|
||||
a:visited { color: #666; }
|
||||
a:hover { color: #fff; background-color:#000; }
|
||||
|
||||
.fieldWithErrors {
|
||||
padding: 2px;
|
||||
background-color: red;
|
||||
display: table;
|
||||
}
|
||||
|
||||
#errorExplanation {
|
||||
width: 400px;
|
||||
border: 2px solid red;
|
||||
padding: 7px;
|
||||
padding-bottom: 12px;
|
||||
margin-bottom: 20px;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
#errorExplanation h2 {
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 5px 5px 5px 15px;
|
||||
font-size: 12px;
|
||||
margin: -7px;
|
||||
background-color: #c00;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#errorExplanation p {
|
||||
color: #333;
|
||||
margin-bottom: 0;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#errorExplanation ul li {
|
||||
font-size: 12px;
|
||||
list-style: square;
|
||||
}
|
||||
|
2
test/fixtures/articles.yml
vendored
2
test/fixtures/articles.yml
vendored
|
@ -1,5 +1,5 @@
|
|||
# == Schema Information
|
||||
# Schema version: 20090102171850
|
||||
# Schema version: 20090113111624
|
||||
#
|
||||
# Table name: articles
|
||||
#
|
||||
|
|
2
test/fixtures/suppliers.yml
vendored
2
test/fixtures/suppliers.yml
vendored
|
@ -1,5 +1,5 @@
|
|||
# == Schema Information
|
||||
# Schema version: 20090102171850
|
||||
# Schema version: 20090113111624
|
||||
#
|
||||
# Table name: suppliers
|
||||
#
|
||||
|
|
7
test/fixtures/workgroups.yml
vendored
Normal file
7
test/fixtures/workgroups.yml
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
# one:
|
||||
# column: value
|
||||
#
|
||||
# two:
|
||||
# column: value
|
8
test/functional/admin/groups_controller_test.rb
Normal file
8
test/functional/admin/groups_controller_test.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Admin::GroupsControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
8
test/functional/admin/memberships_controller_test.rb
Normal file
8
test/functional/admin/memberships_controller_test.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Admin::MembershipsControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
45
test/functional/workgroups_controller_test.rb
Normal file
45
test/functional/workgroups_controller_test.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
require 'test_helper'
|
||||
|
||||
class WorkgroupsControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:workgroups)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create workgroup" do
|
||||
assert_difference('Workgroup.count') do
|
||||
post :create, :workgroup => { }
|
||||
end
|
||||
|
||||
assert_redirected_to workgroup_path(assigns(:workgroup))
|
||||
end
|
||||
|
||||
test "should show workgroup" do
|
||||
get :show, :id => workgroups(:one).id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, :id => workgroups(:one).id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update workgroup" do
|
||||
put :update, :id => workgroups(:one).id, :workgroup => { }
|
||||
assert_redirected_to workgroup_path(assigns(:workgroup))
|
||||
end
|
||||
|
||||
test "should destroy workgroup" do
|
||||
assert_difference('Workgroup.count', -1) do
|
||||
delete :destroy, :id => workgroups(:one).id
|
||||
end
|
||||
|
||||
assert_redirected_to workgroups_path
|
||||
end
|
||||
end
|
8
test/unit/workgroup_test.rb
Normal file
8
test/unit/workgroup_test.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
require 'test_helper'
|
||||
|
||||
class WorkgroupTest < ActiveSupport::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue