Moved User.address-info into Ordergroup.contact_... attributes. Updated model-fixtures for testing.

This commit is contained in:
Benjamin Meichsner 2009-02-02 16:35:43 +01:00
parent aa47a24fda
commit 0a2a79237a
60 changed files with 466 additions and 443 deletions

View File

@ -10,10 +10,8 @@ class Finance::TransactionsController < ApplicationController
if params["sort"]
sort = case params["sort"]
when "name" then "name"
when "size" then "actual_size"
when "account_balance" then "account_balance"
when "name_reverse" then "name DESC"
when "size_reverse" then "actual_size DESC"
when "account_balance_reverse" then "account_balance DESC"
end
else

View File

@ -39,7 +39,7 @@ class HomeController < ApplicationController
@user = @current_user
@ordergroup = @user.ordergroup
@ordergroup_column_names = ["Description", "Actual Size", "Balance", "Updated"]
@ordergroup_columns = ["description", "actual_size", "account_balance", "account_updated"]
@ordergroup_columns = ["description", "account_balance", "account_updated"]
#listing the financial transactions with ajax...

View File

@ -117,4 +117,20 @@ module ApplicationHelper
remote_options = {:before => "Element.show('loader')", :success => "Element.hide('loader')"}
link_to_remote(text, remote_options.merge(options))
end
def format_roles(record)
roles = []
roles << 'Admin' if record.role_admin?
roles << 'Finanzen' if record.role_finance?
roles << 'Lieferanten' if record.role_suppliers?
roles << 'Artikel' if record.role_article_meta?
roles << 'Bestellung' if record.role_orders?
roles.join(', ')
end
def link_to_gmaps(address)
link_to h(address), "http://maps.google.de/?q=#{h(address)}", :title => "Show it on google maps",
:target => "_blank"
end
end

View File

@ -3,24 +3,24 @@
#
# Table name: articles
#
# id :integer(4) not null, primary key
# id :integer 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
# supplier_id :integer default(0), not null
# article_category_id :integer default(0), not null
# unit :string(255) default(""), not null
# note :string(255)
# availability :boolean(1) default(TRUE), not null
# availability :boolean default(TRUE), not null
# manufacturer :string(255)
# origin :string(255)
# shared_updated_on :datetime
# price :decimal(8, 2)
# price :decimal(, )
# tax :float
# deposit :decimal(8, 2) default(0.0)
# unit_quantity :integer(4) default(1), not null
# deposit :decimal(, ) default(0.0)
# unit_quantity :integer default(1), not null
# order_number :string(255)
# created_at :datetime
# updated_at :datetime
# quantity :decimal(6, 2) default(0.0)
# quantity :decimal(, ) default(0.0)
# deleted_at :datetime
#

View File

@ -1,9 +1,9 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090119155930
#
# Table name: article_categories
#
# id :integer(4) not null, primary key
# id :integer not null, primary key
# name :string(255) default(""), not null
# description :string(255)
#

View File

@ -1,14 +1,14 @@
# == Schema Information
# Schema version: 20090120184410
# Schema version: 20090119155930
#
# Table name: article_prices
#
# id :integer(4) not null, primary key
# article_id :integer(4)
# id :integer not null, primary key
# article_id :integer
# price :decimal(8, 2) default(0.0), not null
# tax :decimal(8, 2) default(0.0), not null
# deposit :decimal(8, 2) default(0.0), not null
# unit_quantity :integer(4)
# unit_quantity :integer
# created_at :datetime
#

View File

@ -1,12 +1,12 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090119155930
#
# Table name: assignments
#
# id :integer(4) not null, primary key
# user_id :integer(4) default(0), not null
# task_id :integer(4) default(0), not null
# accepted :boolean(1)
# id :integer not null, primary key
# user_id :integer default(0), not null
# task_id :integer default(0), not null
# accepted :boolean
#
class Assignment < ActiveRecord::Base

View File

@ -1,10 +1,10 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090119155930
#
# Table name: deliveries
#
# id :integer(4) not null, primary key
# supplier_id :integer(4)
# id :integer not null, primary key
# supplier_id :integer
# delivered_on :date
# created_at :datetime
#

View File

@ -1,13 +1,13 @@
# == Schema Information
# Schema version: 20090114101610
# Schema version: 20090119155930
#
# Table name: financial_transactions
#
# id :integer(4) not null, primary key
# ordergroup_id :integer(4) default(0), not null
# id :integer not null, primary key
# ordergroup_id :integer default(0), not null
# amount :decimal(8, 2) default(0.0), not null
# note :text default(""), not null
# user_id :integer(4) default(0), not null
# note :text not null
# user_id :integer default(0), not null
# created_on :datetime not null
#

View File

@ -3,25 +3,27 @@
#
# Table name: groups
#
# id :integer(4) not null, primary key
# id :integer 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_balance :decimal(, ) 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)
# role_admin :boolean not null
# role_suppliers :boolean not null
# role_article_meta :boolean not null
# role_finance :boolean not null
# role_orders :boolean not null
# weekly_task :boolean
# weekday :integer
# task_name :string(255)
# task_description :string(255)
# task_required_users :integer(4) default(1)
# task_required_users :integer default(1)
# deleted_at :datetime
# contact_person :string(255)
# contact_phone :string(255)
# contact_address :string(255)
#
# Groups organize the User.

View File

@ -1,15 +1,15 @@
# == Schema Information
# Schema version: 20090120184410
# Schema version: 20090119155930
#
# Table name: group_orders
#
# id :integer(4) not null, primary key
# ordergroup_id :integer(4) default(0), not null
# order_id :integer(4) default(0), not null
# id :integer not null, primary key
# ordergroup_id :integer default(0), not null
# order_id :integer default(0), not null
# price :decimal(8, 2) default(0.0), not null
# lock_version :integer(4) default(0), not null
# lock_version :integer default(0), not null
# updated_on :datetime not null
# updated_by_user_id :integer(4)
# updated_by_user_id :integer
#
# A GroupOrder represents an Order placed by an Ordergroup.

View File

@ -1,13 +1,13 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090119155930
#
# Table name: group_order_articles
#
# id :integer(4) not null, primary key
# group_order_id :integer(4) default(0), not null
# order_article_id :integer(4) default(0), not null
# quantity :integer(4) default(0), not null
# tolerance :integer(4) default(0), not null
# id :integer not null, primary key
# group_order_id :integer default(0), not null
# order_article_id :integer default(0), not null
# quantity :integer default(0), not null
# tolerance :integer default(0), not null
# updated_on :datetime not null
#

View File

@ -1,12 +1,12 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090119155930
#
# Table name: group_order_article_quantities
#
# id :integer(4) not null, primary key
# group_order_article_id :integer(4) default(0), not null
# quantity :integer(4) default(0)
# tolerance :integer(4) default(0)
# id :integer not null, primary key
# group_order_article_id :integer default(0), not null
# quantity :integer default(0)
# tolerance :integer default(0)
# created_on :datetime not null
#

View File

@ -1,13 +1,13 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090119155930
#
# Table name: invites
#
# id :integer(4) not null, primary key
# id :integer not null, primary key
# token :string(255) default(""), not null
# expires_at :datetime not null
# group_id :integer(4) default(0), not null
# user_id :integer(4) default(0), not null
# group_id :integer default(0), not null
# user_id :integer default(0), not null
# email :string(255) default(""), not null
#

View File

@ -1,11 +1,11 @@
# == Schema Information
# Schema version: 20090120184410
# Schema version: 20090119155930
#
# Table name: invoices
#
# id :integer(4) not null, primary key
# supplier_id :integer(4)
# delivery_id :integer(4)
# id :integer not null, primary key
# supplier_id :integer
# delivery_id :integer
# number :string(255)
# date :date
# paid_on :date
@ -13,7 +13,7 @@
# amount :decimal(8, 2) default(0.0), not null
# created_at :datetime
# updated_at :datetime
# order_id :integer(4)
# order_id :integer
# deposit :decimal(8, 2) default(0.0), not null
# deposit_credit :decimal(8, 2) default(0.0), not null
#

View File

@ -1,11 +1,11 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090119155930
#
# Table name: memberships
#
# id :integer(4) not null, primary key
# group_id :integer(4) default(0), not null
# user_id :integer(4) default(0), not null
# id :integer not null, primary key
# group_id :integer default(0), not null
# user_id :integer default(0), not null
#
class Membership < ActiveRecord::Base

View File

@ -1,15 +1,15 @@
# == Schema Information
# Schema version: 20090115232435
# Schema version: 20090119155930
#
# Table name: messages
#
# id :integer(4) not null, primary key
# sender_id :integer(4)
# id :integer not null, primary key
# sender_id :integer
# recipients_ids :text
# subject :string(255) not null
# body :text
# email_state :integer(4) default(0), not null
# private :boolean(1)
# email_state :integer default(0), not null
# private :boolean
# created_at :datetime
#

View File

@ -1,16 +1,16 @@
# == Schema Information
# Schema version: 20090120184410
# Schema version: 20090119155930
#
# Table name: orders
#
# id :integer(4) not null, primary key
# supplier_id :integer(4)
# id :integer not null, primary key
# supplier_id :integer
# note :text
# starts :datetime
# ends :datetime
# state :string(255) default("open")
# lock_version :integer(4) default(0), not null
# updated_by_user_id :integer(4)
# lock_version :integer default(0), not null
# updated_by_user_id :integer
#
class Order < ActiveRecord::Base

View File

@ -1,16 +1,16 @@
# == Schema Information
# Schema version: 20090120184410
# Schema version: 20090119155930
#
# Table name: order_articles
#
# id :integer(4) not null, primary key
# order_id :integer(4) default(0), not null
# article_id :integer(4) default(0), not null
# quantity :integer(4) default(0), not null
# tolerance :integer(4) default(0), not null
# units_to_order :integer(4) default(0), not null
# lock_version :integer(4) default(0), not null
# article_price_id :integer(4)
# id :integer not null, primary key
# order_id :integer default(0), not null
# article_id :integer default(0), not null
# quantity :integer default(0), not null
# tolerance :integer default(0), not null
# units_to_order :integer default(0), not null
# lock_version :integer default(0), not null
# article_price_id :integer
#
# An OrderArticle represents a single Article that is part of an Order.

View File

@ -1,11 +1,11 @@
# == Schema Information
# Schema version: 20090120184410
# Schema version: 20090119155930
#
# Table name: order_comments
#
# id :integer(4) not null, primary key
# order_id :integer(4)
# user_id :integer(4)
# id :integer not null, primary key
# order_id :integer
# user_id :integer
# text :text
# created_at :datetime
#

View File

@ -3,25 +3,27 @@
#
# Table name: groups
#
# id :integer(4) not null, primary key
# id :integer 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_balance :decimal(, ) 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)
# role_admin :boolean not null
# role_suppliers :boolean not null
# role_article_meta :boolean not null
# role_finance :boolean not null
# role_orders :boolean not null
# weekly_task :boolean
# weekday :integer
# task_name :string(255)
# task_description :string(255)
# task_required_users :integer(4) default(1)
# task_required_users :integer default(1)
# deleted_at :datetime
# contact_person :string(255)
# contact_phone :string(255)
# contact_address :string(255)
#
# Ordergroups can order, they are "children" of the class Group
@ -29,7 +31,6 @@
# Ordergroup have the following attributes, in addition to Group
# * account_balance (decimal)
# * account_updated (datetime)
# * actual_size (int) : how many persons are ordering through the Ordergroup
class Ordergroup < Group
acts_as_paranoid # Avoid deleting the ordergroup for consistency of order-results
extend ActiveSupport::Memoizable # Ability to cache method results. Use memoize :expensive_method
@ -38,9 +39,11 @@ class Ordergroup < Group
has_many :group_orders
has_many :orders, :through => :group_orders
validates_inclusion_of :actual_size, :in => 1..99
validates_numericality_of :account_balance, :message => 'ist keine gültige Zahl'
def contact
"#{contact_phone} (#{contact_person})"
end
def non_members
User.all(:order => 'nick').reject { |u| (users.include?(u) || u.ordergroup) }
end

View File

@ -1,12 +1,12 @@
# == Schema Information
# Schema version: 20090115232435
# Schema version: 20090119155930
#
# Table name: stock_changes
#
# id :integer(4) not null, primary key
# delivery_id :integer(4)
# order_id :integer(4)
# article_id :integer(4)
# id :integer not null, primary key
# delivery_id :integer
# order_id :integer
# article_id :integer
# quantity :decimal(6, 2) default(0.0)
# created_at :datetime
#

View File

@ -3,7 +3,7 @@
#
# Table name: suppliers
#
# id :integer(4) not null, primary key
# id :integer not null, primary key
# name :string(255) default(""), not null
# address :string(255) default(""), not null
# phone :string(255) default(""), not null
@ -16,7 +16,7 @@
# delivery_days :string(255)
# order_howto :string(255)
# note :string(255)
# shared_supplier_id :integer(4)
# shared_supplier_id :integer
# min_order_quantity :string(255)
# deleted_at :datetime
#

View File

@ -1,18 +1,18 @@
# == Schema Information
# Schema version: 20090114101610
# Schema version: 20090119155930
#
# Table name: tasks
#
# id :integer(4) not null, primary key
# id :integer not null, primary key
# name :string(255) default(""), not null
# description :string(255)
# due_date :date
# done :boolean(1)
# workgroup_id :integer(4)
# assigned :boolean(1)
# done :boolean
# workgroup_id :integer
# assigned :boolean
# created_on :datetime not null
# updated_on :datetime not null
# required_users :integer(4) default(1)
# required_users :integer default(1)
#
class Task < ActiveRecord::Base

View File

@ -1,9 +1,9 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090120184410
#
# Table name: users
#
# id :integer(4) not null, primary key
# id :integer not null, primary key
# nick :string(255) default(""), not null
# password_hash :string(255) default(""), not null
# password_salt :string(255) default(""), not null
@ -11,7 +11,6 @@
# last_name :string(255) default(""), not null
# email :string(255) default(""), not null
# phone :string(255)
# address :string(255)
# created_on :datetime not null
# reset_password_token :string(255)
# reset_password_expires :datetime
@ -80,6 +79,13 @@ class User < ActiveRecord::Base
end
end
def name
[first_name, last_name].join(" ")
end
def ordergroup_name
ordergroup.name if ordergroup
end
# Sets the user's password. It will be stored encrypted along with a random salt.
def set_password
@ -94,22 +100,6 @@ class User < ActiveRecord::Base
Digest::SHA1.hexdigest(password + self.password_salt) == self.password_hash
end
# # Sets the passwort, and if fails it returns error-messages (see above)
# def set_password(options = {:required => false}, password = nil, confirmation = nil)
# required = options[:required]
# if required && (password.nil? || password.empty?)
# self.errors.add_to_base 'Password is required'
# elsif !password.nil? && !password.empty?
# if password != confirmation
# self.errors.add_to_base "Passwords doesn't match"
# elsif password.length < 5 || password.length > 25
# self.errors.add_to_base 'Password-length has to be between 5 and 25 characters'
# else
# self.password = password
# end
# end
# end
# Returns a random password.
def new_random_password(size = 3)
c = %w(b c d f g h j k l m n p qu r s t v w x z ch cr fr nd ng nk nt ph pr rd sh sl sp st th tr)

View File

@ -3,25 +3,27 @@
#
# Table name: groups
#
# id :integer(4) not null, primary key
# id :integer 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_balance :decimal(, ) 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)
# role_admin :boolean not null
# role_suppliers :boolean not null
# role_article_meta :boolean not null
# role_finance :boolean not null
# role_orders :boolean not null
# weekly_task :boolean
# weekday :integer
# task_name :string(255)
# task_description :string(255)
# task_required_users :integer(4) default(1)
# task_required_users :integer default(1)
# deleted_at :datetime
# contact_person :string(255)
# contact_phone :string(255)
# contact_address :string(255)
#
class Workgroup < Group

View File

@ -14,7 +14,7 @@
- for user in @users
%tr{:class => cycle('even','odd', :name => 'users')}
%td= link_to user.nick, [:admin, user]
%td= [user.first_name, user.last_name].join(", ")
%td=h user.name
%td= format_date(user.created_on)
%br/
= link_to 'Alle Benutzerinnen', admin_users_path

View File

@ -1,11 +1,18 @@
- form_for [:admin, @ordergroup] do |@form|
= render :partial => 'shared/group_form'
%div{:style => "float:left;width:55%;"}
%p
= @form.label :actual_size, "Aktuelle Gruppengröße"
%br/
= @form.text_field :actual_size, :size => 3
- render :layout => 'shared/group_form' do
%div{:style => "float:right;width:40%"}
%p
= @form.label :contact_person
%br/
= @form.text_field :contact_person, :size => 20
%p
= @form.label :contact_phone
%br/
= @form.text_field :contact_phone, :size => 20
%p
= @form.label :contact_address
%br/
= @form.text_field :contact_address
%br{ :style => "clear:both" }
= submit_tag "Speichern"

View File

@ -10,12 +10,16 @@
%thead
%tr
%th Name
%th Kontakt
%th Adresse
%th Mitglieder
%th
%tbody
- for ordergroup in @ordergroups
%tr{:class => cycle('even','odd', :name => 'groups')}
%td= link_to ordergroup.name, [:admin, ordergroup]
%td= ordergroup.contact
%td= link_to_gmaps ordergroup.contact_address
%td= ordergroup.users.size
%td
= link_to image_tag('b_users.png', :size => '16x16', :border => "0", :alt => 'Mitlglieder bearbeiten'), memberships_admin_ordergroup_path(ordergroup)

View File

@ -9,30 +9,23 @@
%table.list
%thead
%tr
%th= _('Username')
%th= _('First name')
%th= _('Last name')
%th= _('Email')
%th= _('Roles')
%th= _('Last Login')
%th Login
%th Name
%th Email
%th Zugriff auf
%th Letzter login
%th{:style => "width:3em"}
%tbody
- for user in @users
- roles = Array.new
- roles << 'Admin' if user.role_admin?
- roles << 'Finanzen' if user.role_finance?
- roles << 'Lieferanten' if user.role_suppliers?
- roles << 'Artikel' if user.role_article_meta?
- roles << 'Bestellung' if user.role_orders?
%tr{:class => cycle('even','odd', :name => 'users')}
%td= link_to user.nick, [:admin, user]
%td=h user.first_name
%td=h user.last_name
%td=h user.name
%td=h user.email
%td=h roles.join(', ')
%td=h format_roles(user)
%td=h format_time(user.last_login)
%td
= link_to(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => 'Benutzer_in bearbeiten', :title => 'Benutzer_in bearbeiten'), edit_admin_user_path(user))
= link_to(image_tag('b_drop.png', :size => "16x16", :border => "0", :alt => 'Benutzer_in löschen', :title => 'Benutzer_in löschen'), |
[:admin, user], |
:confirm => 'Willst du ' + user.first_name + ' wirklich löschen?', :method => :delete) |
:confirm => 'Willst du ' + user.name + ' wirklich löschen?', :method => :delete) |

View File

@ -10,10 +10,9 @@
<div style="float:left;margin:5px; margin-right:10px;" class="box">
<p><b>Person</b></p>
<p><b>Nick:</b> <%=h @user.nick %></p>
<p><b>Name:</b> <%=h @user.first_name + ' ' + @user.last_name %></p>
<p><b>Name:</b> <%=h @user.name %></p>
<p><b>Email:</b> <%=h @user.email %></p>
<p><b>Telefon:</b> <%=h @user.phone %></p>
<p><b>Adresse:</b> <%=h @user.address %></p>
</div>
<div style="float:left; margin:5px;" class="box">
<p>
@ -32,14 +31,8 @@
<p>
<b>Benutzer_in hat Zugriff auf:</b>
</p>
<% roles = Array.new
roles << 'Admin' if @user.role_admin?
roles << 'Finanzen' if @user.role_finance?
roles << 'Lieferanten' if @user.role_suppliers?
roles << 'Artikel' if @user.role_article_meta?
roles << 'Bestellung' if @user.role_orders? %>
<p>
<%=h roles.join(', ') %>
<%=h format_roles(@user) %>
</p>
</div>
<p style="clear:both">

View File

@ -11,14 +11,16 @@
%tr
%th Name
%th Mitglieder
%th Zugriff auf
%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= format_roles(workgroup)
%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) |
:confirm => 'Willst du ' + workgroup.name + ' wirklich löschen?', :method => :delete) |

View File

@ -13,14 +13,14 @@
%thead
%tr
%th= sort_link_helper _("Name"), "name", @per_page
%th= sort_link_helper _("Size of group"), "size", @per_page
%th Kontakt
%th= sort_link_helper _("Account balance"), "account_balance", @per_page
%th
%tbody
- for group in @groups
%tr{:class => cycle('even','odd', :name => 'groups')}
%td= group.name
%td= group.actual_size
%td= group.contact
%td{:class => "currency", :style => "width:5em"}= number_to_currency(group.account_balance)
%td{:class => "actions"}
= link_to image_tag("euro_new.png", :size => "16x16", :alt => _("New transaction"), :border => "0"), {:action => 'new', :id => group}, {:title => _("New transaction")}

View File

@ -23,4 +23,4 @@
= render :partial => "ordergroups"
%br/
- if @current_user.role_admin?
= link_to _("New ordergroup"), :controller => 'admin', :action => 'newOrdergroup'
= link_to "Neue Bestellgruppe anlegen", new_admin_ordergroup_path

View File

@ -11,8 +11,7 @@
%thead
%tr
%th Nick
%th Vorname
%th Nachname
%th Name
%th Email
%th Telefon
%th Bestellgruppe
@ -20,14 +19,10 @@
%tbody
- for user in @users
%tr{:class => cycle('even','odd', :name => 'users')}
- groups = user.groups
- ordergroup = groups.detect { |group| group.is_a?(Ordergroup) }
- workgroups = groups.select { |group| !group.is_a?(Ordergroup) }.collect(&:name)
%td= link_to user.nick, {:controller => "messages", :action => "user", :id => user}, :title => _('Send user an email')
%td=h user.first_name if @current_user.role_admin? || user.settings["profile.nameIsPublic"] == '1'
%td=h user.last_name if @current_user.role_admin? || user.settings["profile.nameIsPublic"] == '1'
%td=h user.name if @current_user.role_admin? || user.settings["profile.nameIsPublic"] == '1'
%td=h user.email if @current_user.role_admin? || user.settings["profile.emailIsPublic"] == '1'
%td=h user.phone if @current_user.role_admin? || user.settings["profile.phoneIsPublic"] == '1'
%td=h ordergroup.name if ordergroup
%td=h workgroups.join(', ')
%td=h user.ordergroup_name
%td=h groups.select { |group| !group.is_a?(Ordergroup) }.collect(&:name).join(', ')

View File

@ -5,7 +5,6 @@
<p><b>Beschreibung:</b> <%=h @ordergroup.description %>
<%= link_to '(ändern)', :controller => 'foodcoop', :action => 'edit_group', :id => @ordergroup %>
</p>
<p><b>Gruppengröße:</b> <%=h @ordergroup.actual_size %></p>
<p><b>Kontostand:</b> <%= number_to_currency(@ordergroup.account_balance) %></p>
<h2>Personen</h2>
<ul style="list-style-type:decimal;">

View File

@ -31,10 +31,6 @@
Telefon
%br/
= form.text_field :phone
%p
Adresse
%br/
= form.text_field :address
%p
Passwort
%br/

View File

@ -2,16 +2,16 @@
%tr
%td Beschreibung:
%td=h group.description
- if @current_user.role_admin? or @current_user.role_finance?
%tr
%td Kontakt:
%td=h group.contact
%tr
%td Adresse:
%td= link_to_gmaps group.contact_address
%tr
%td Gruppe hat Zugriff auf:
%td
- roles = Array.new
- roles << 'Administration' if group.role_admin?
- roles << 'Finanzen' if group.role_finance?
- roles << 'Lieferanten' if group.role_suppliers?
- roles << 'Artikel' if group.role_article_meta?
- roles << 'Bestellungsverwaltung' if group.role_orders?
= roles.join(', ')
%td= format_roles(group)
%tr
%td Mitglieder:
%td

View File

@ -21,10 +21,6 @@
<td><%= @form.label :phone %></td>
<td><%= @form.text_field :phone %></td>
</tr>
<tr>
<td><%= @form.label :address %></td>
<td><%= @form.text_field :address %></td>
</tr>
<tr>
<td/>
</tr>

View File

@ -67,6 +67,7 @@ Rails::Initializer.run do |config|
# library for parsing/writing files from/to csv-file
config.gem "fastercsv"
config.gem "prawn"
config.gem "haml", :version => '>=2.0.6'
# The internationalization framework can be changed to have another default locale (standard is :en) or more load paths.
# All files from config/locales/*.rb,yml are added automatically.

View File

@ -0,0 +1,28 @@
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_view.debug_rjs = true
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Configure an SMTP server for email sending in development mode:
# (cf. http://rails.rubyonrails.com/classes/ActionMailer/Base.html for info on options)
config.action_mailer.smtp_settings = {
:address => "smtp.gmx.net",
:port => 25,
:domain => "gmx.net",
:authentication => :login,
:user_name => "benjamin.meichsner@gmx.de",
:password => "ben234go"
}

View File

@ -2,12 +2,28 @@ class RefactorOrderLogic < ActiveRecord::Migration
def self.up
# TODO: Combine migrations since foodsoft3-development into one file
# and try to build a migration path from old data.
# # articles
# == Ordergroups
add_column :groups, :deleted_at, :datetime # acts_as_paranoid
remove_column :groups, :actual_size # Useless, desposits are better stored within a transaction.note
# move contact-infos from users to ordergroups
add_column :groups, :contact_person, :string
add_column :groups, :contact_phone, :string
add_column :groups, :contact_address, :string
Ordergroup.all.each do |ordergroup|
contact = ordergroup.users.first
if contact
ordergroup.update_attributes :contact_person => contact.name,
:contact_phone => contact.phone, :contact_address => contact.address
end
end
remove_column :users, :address
#
# # == Article
# rename_column :articles, :net_price, :price
# remove_column :articles, :gross_price
#
# # orders
# # == Order
# drop_table :orders
# drop_table :group_order_results
# drop_table :order_article_results
@ -24,12 +40,12 @@ class RefactorOrderLogic < ActiveRecord::Migration
# t.integer :updated_by_user_id
# end
#
# # invoices
# # == Invoice
# add_column :invoices, :order_id, :integer
# add_column :invoices, :deposit, :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
# add_column :invoices, :deposit_credit, :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
#
# # comments
# # == Comment
# drop_table :comments
# create_table :order_comments do |t|
# t.references :order
@ -38,7 +54,7 @@ class RefactorOrderLogic < ActiveRecord::Migration
# t.datetime :created_at
# end
#
# # article_prices
# # == ArticlePrice
# create_table :article_prices do |t|
# t.references :article
# t.decimal :price, :precision => 8, :scale => 2, :default => 0.0, :null => false
@ -59,11 +75,8 @@ class RefactorOrderLogic < ActiveRecord::Migration
# # order-articles
# add_column :order_articles, :article_price_id, :integer
#
# # ordergroups
# add_column :groups, :deleted_at, :datetime
# GroupOrders
change_column :group_orders, :updated_by_user_id, :integer, :default => nil, :null => true
# # == GroupOrder
# change_column :group_orders, :updated_by_user_id, :integer, :default => nil, :null => true
end
def self.down

View File

@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20090119155930) do
ActiveRecord::Schema.define(:version => 20090120184410) do
create_table "article_categories", :force => true do |t|
t.string "name", :default => "", :null => false
@ -28,23 +28,23 @@ ActiveRecord::Schema.define(:version => 20090119155930) do
end
create_table "articles", :force => true do |t|
t.string "name", :default => "", :null => false
t.integer "supplier_id", :default => 0, :null => false
t.integer "article_category_id", :default => 0, :null => false
t.string "unit", :default => "", :null => false
t.string "name", :default => "", :null => false
t.integer "supplier_id", :default => 0, :null => false
t.integer "article_category_id", :default => 0, :null => false
t.string "unit", :default => "", :null => false
t.string "note"
t.boolean "availability", :default => true, :null => false
t.boolean "availability", :default => true, :null => false
t.string "manufacturer"
t.string "origin"
t.datetime "shared_updated_on"
t.decimal "price", :precision => 8, :scale => 2
t.decimal "price"
t.float "tax"
t.decimal "deposit", :precision => 8, :scale => 2, :default => 0.0
t.integer "unit_quantity", :default => 1, :null => false
t.decimal "deposit", :default => 0.0
t.integer "unit_quantity", :default => 1, :null => false
t.string "order_number"
t.datetime "created_at"
t.datetime "updated_at"
t.decimal "quantity", :precision => 6, :scale => 2, :default => 0.0
t.decimal "quantity", :default => 0.0
t.datetime "deleted_at"
end
@ -113,24 +113,26 @@ ActiveRecord::Schema.define(:version => 20090119155930) do
add_index "group_orders", ["ordergroup_id", "order_id"], :name => "index_group_orders_on_ordergroup_id_and_order_id", :unique => true
create_table "groups", :force => true do |t|
t.string "type", :default => "", :null => false
t.string "name", :default => "", :null => false
t.string "type", :default => "", :null => false
t.string "name", :default => "", :null => false
t.string "description"
t.integer "actual_size"
t.decimal "account_balance", :precision => 8, :scale => 2, :default => 0.0, :null => false
t.decimal "account_balance", :default => 0.0, :null => false
t.datetime "account_updated"
t.datetime "created_on", :null => false
t.boolean "role_admin", :default => false, :null => false
t.boolean "role_suppliers", :default => false, :null => false
t.boolean "role_article_meta", :default => false, :null => false
t.boolean "role_finance", :default => false, :null => false
t.boolean "role_orders", :default => false, :null => false
t.boolean "weekly_task", :default => false
t.datetime "created_on", :null => false
t.boolean "role_admin", :default => false, :null => false
t.boolean "role_suppliers", :default => false, :null => false
t.boolean "role_article_meta", :default => false, :null => false
t.boolean "role_finance", :default => false, :null => false
t.boolean "role_orders", :default => false, :null => false
t.boolean "weekly_task", :default => false
t.integer "weekday"
t.string "task_name"
t.string "task_description"
t.integer "task_required_users", :default => 1
t.integer "task_required_users", :default => 1
t.datetime "deleted_at"
t.string "contact_person"
t.string "contact_phone"
t.string "contact_address"
end
add_index "groups", ["name"], :name => "index_groups_on_name", :unique => true
@ -257,7 +259,6 @@ ActiveRecord::Schema.define(:version => 20090119155930) do
t.string "last_name", :default => "", :null => false
t.string "email", :default => "", :null => false
t.string "phone"
t.string "address"
t.datetime "created_on", :null => false
t.string "reset_password_token"
t.datetime "reset_password_expires"

View File

@ -1,14 +1,16 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090119155930
#
# Table name: article_categories
#
# id :integer(4) not null, primary key
# id :integer not null, primary key
# name :string(255) default(""), not null
# description :string(255)
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
fruits:
id: 1
name: Fruits
description: fruits and only fruits
vegi:
name: Vegetables

View File

@ -1,27 +1,39 @@
# == Schema Information
# Schema version: 20090120184410
# Schema version: 20090119155930
#
# Table name: article_prices
#
# id :integer(4) not null, primary key
# article_id :integer(4)
# id :integer not null, primary key
# article_id :integer
# price :decimal(8, 2) default(0.0), not null
# tax :decimal(8, 2) default(0.0), not null
# deposit :decimal(8, 2) default(0.0), not null
# unit_quantity :integer(4)
# unit_quantity :integer
# created_at :datetime
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
price: 9.99
tax: 9.99
deposit: 9.99
unit_quantity: 1
banana1:
article: banana
price: 1.45
tax: 7.0
unit_quantity: 18
two:
price: 9.99
tax: 9.99
deposit: 9.99
unit_quantity: 1
banana2:
article: banana
price: 1.35
tax: 7.0
unit_quantity: 18
kiwi1:
article: kiwi
price: 1.11
tax: 7.0
unit_quantity: 10
potatoe1:
article: potatoe
price: 1.33
tax: 7.0
unit_quantity: 25

View File

@ -3,53 +3,59 @@
#
# Table name: articles
#
# id :integer(4) not null, primary key
# id :integer 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
# supplier_id :integer default(0), not null
# article_category_id :integer default(0), not null
# unit :string(255) default(""), not null
# note :string(255)
# availability :boolean(1) default(TRUE), not null
# availability :boolean default(TRUE), not null
# manufacturer :string(255)
# origin :string(255)
# shared_updated_on :datetime
# price :decimal(8, 2)
# price :decimal(, )
# tax :float
# deposit :decimal(8, 2) default(0.0)
# unit_quantity :integer(4) default(1), not null
# deposit :decimal(, ) default(0.0)
# unit_quantity :integer default(1), not null
# order_number :string(255)
# created_at :datetime
# updated_at :datetime
# quantity :decimal(6, 2) default(0.0)
# quantity :decimal(, ) default(0.0)
# deleted_at :datetime
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
banana:
id: 1
name: banana
current_price_id: 1
unit: 500g
availability: 1
supplier: terra
name: Banana
article_category: fruits
unit: KG
availability: true
note: delicious
supplier_id: 1
article_category_id: 1
origin: EC
price: 1.45
tax: 7.0
unit_quantity: 18
order_number: 123456
kiwi:
id: 2
name: kiwi
current_price_id: 2
supplier: terra
name: Kiwi
article_category: fruits
unit: 500g
availability: 1
note: delicious
supplier_id: 1
article_category_id: 1
apple:
id: 3
name: apple
current_price_id: 3
availability: true
origin: IT
price: 1.11
tax: 7.0
unit_quantity: 10
order_number: 123457
potatoe:
supplier: terra
name: Potatoe
article_category: vegi
unit: 500g
availability: 0
note: delicious
supplier_id: 1
article_category_id: 1
availability: true
origin: REG
price: 1.33
tax: 7.0
unit_quantity: 25
order_number: 123458

View File

@ -1,16 +1,12 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090119155930
#
# Table name: assignments
#
# id :integer(4) not null, primary key
# user_id :integer(4) default(0), not null
# task_id :integer(4) default(0), not null
# accepted :boolean(1)
# id :integer not null, primary key
# user_id :integer default(0), not null
# task_id :integer default(0), not null
# accepted :boolean
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
id: 1
two:
id: 2

View File

@ -1,18 +1,26 @@
# == Schema Information
# Schema version: 20090114101610
# Schema version: 20090119155930
#
# Table name: financial_transactions
#
# id :integer(4) not null, primary key
# ordergroup_id :integer(4) default(0), not null
# id :integer not null, primary key
# ordergroup_id :integer default(0), not null
# amount :decimal(8, 2) default(0.0), not null
# note :text default(""), not null
# user_id :integer(4) default(0), not null
# note :text not null
# user_id :integer default(0), not null
# created_on :datetime not null
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
another:
id: 2
bananas1:
ordergroup: bananas
amount: 0.00
note: "Deposit for 3 people: 15,-€"
user: admin
created_on: <%= 2.weeks.ago.strftime("%d.%m.%Y") %>
bananas2:
ordergroup: bananas
amount: 100.00
note: Paying in from <%= 1.weeks.ago.strftime("%d.%m.%Y") %>
created_on: <%= 1.weeks.ago.strftime("%d.%m.%Y") %>

View File

@ -1,17 +1,14 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090119155930
#
# Table name: group_order_article_quantities
#
# id :integer(4) not null, primary key
# group_order_article_id :integer(4) default(0), not null
# quantity :integer(4) default(0)
# tolerance :integer(4) default(0)
# id :integer not null, primary key
# group_order_article_id :integer default(0), not null
# quantity :integer default(0)
# tolerance :integer default(0)
# created_on :datetime not null
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
another:
id: 2

View File

@ -3,37 +3,44 @@
#
# Table name: groups
#
# id :integer(4) not null, primary key
# id :integer 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_balance :decimal(, ) 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)
# role_admin :boolean not null
# role_suppliers :boolean not null
# role_article_meta :boolean not null
# role_finance :boolean not null
# role_orders :boolean not null
# weekly_task :boolean
# weekday :integer
# task_name :string(255)
# task_description :string(255)
# task_required_users :integer(4) default(1)
# task_required_users :integer default(1)
# deleted_at :datetime
# contact_person :string(255)
# contact_phone :string(255)
# contact_address :string(255)
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
name: Order Group 1
type: Ordergroup
another:
id: 2
name: Order Group 2
type: Ordergroup
admins:
id: 3
type: Workgroup
name: Administrators
role_admin: true
description: System administrators.
role_admin: true
role_suppliers: true
role_article_meta: true
role_finance: true
role_orders: true
bananas:
type: Ordergroup
name: Banangroup
account_balance: 100.00
account_updated: <%= 1.weeks.ago.strftime("%d.%m.%Y") %>
contact_person: Tim
contact_phone: 030 123132456
contact_address: Waldermarstrasse 43, 10988 Berlin

View File

@ -1,20 +1,18 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090119155930
#
# Table name: memberships
#
# id :integer(4) not null, primary key
# group_id :integer(4) default(0), not null
# user_id :integer(4) default(0), not null
# id :integer not null, primary key
# group_id :integer default(0), not null
# user_id :integer default(0), not null
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
group_id: 3
user_id: 1
another:
id: 2
group_id: 1
user_id: 2
group: admins
user: admin
second:
group: bananas
user: test

View File

@ -1,20 +1,17 @@
# == Schema Information
# Schema version: 20090115232435
# Schema version: 20090119155930
#
# Table name: messages
#
# id :integer(4) not null, primary key
# sender_id :integer(4)
# id :integer not null, primary key
# sender_id :integer
# recipients_ids :text
# subject :string(255) not null
# body :text
# email_state :integer(4) default(0), not null
# private :boolean(1)
# email_state :integer default(0), not null
# private :boolean
# created_at :datetime
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
id: 1
two:
id: 2

View File

@ -1,19 +1,13 @@
# == Schema Information
# Schema version: 20090120184410
# Schema version: 20090119155930
#
# Table name: order_comments
#
# id :integer(4) not null, primary key
# order_id :integer(4)
# user_id :integer(4)
# id :integer not null, primary key
# order_id :integer
# user_id :integer
# text :text
# created_at :datetime
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
# one:
# column: value
#
# two:
# column: value

View File

@ -1,20 +1,16 @@
# == Schema Information
# Schema version: 20090120184410
# Schema version: 20090119155930
#
# Table name: orders
#
# id :integer(4) not null, primary key
# supplier_id :integer(4)
# id :integer not null, primary key
# supplier_id :integer
# note :text
# starts :datetime
# ends :datetime
# state :string(255) default("open")
# lock_version :integer(4) default(0), not null
# updated_by_user_id :integer(4)
# lock_version :integer default(0), not null
# updated_by_user_id :integer
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
another:
id: 2

View File

@ -1,5 +0,0 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
another:
id: 2

View File

@ -1,28 +1,14 @@
# == Schema Information
# Schema version: 20090115232435
# Schema version: 20090119155930
#
# Table name: stock_changes
#
# id :integer(4) not null, primary key
# delivery_id :integer(4)
# order_id :integer(4)
# article_id :integer(4)
# id :integer not null, primary key
# delivery_id :integer
# order_id :integer
# article_id :integer
# quantity :decimal(6, 2) default(0.0)
# created_at :datetime
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
delivery:
order:
article:
quantity: 1
created_at: 2009-01-16 00:24:35
two:
delivery:
order:
article:
quantity: 1
created_at: 2009-01-16 00:24:35

View File

@ -19,17 +19,20 @@
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
terra:
name: Terra
delivery_days: tuesday
contact_person: thomas terra
url: www.terra-natur.de
note:
fax: 01324-343444
phone: 0123-555555
order_howto:
phone2: 01234-7878787
address: berlin bio
customer_number: 123478
phone: 0123-555555
phone2: 01234-7878787
fax: 01324-343444
email: terra@terra.com
url: www.terra-natur.de
contact_person: Harry
customer_number: 123478
delivery_days: tuesday
order_howto: call or send email/fax
note:
Terra possibly delivers also on other days than tuesday. Don't
hesitate to ask for it.
min_order_quantity: 80,-€ (gross)

View File

@ -1,22 +1,18 @@
# == Schema Information
# Schema version: 20090114101610
# Schema version: 20090119155930
#
# Table name: tasks
#
# id :integer(4) not null, primary key
# id :integer not null, primary key
# name :string(255) default(""), not null
# description :string(255)
# due_date :date
# done :boolean(1)
# workgroup_id :integer(4)
# assigned :boolean(1)
# done :boolean
# workgroup_id :integer
# assigned :boolean
# created_on :datetime not null
# updated_on :datetime not null
# required_users :integer(4) default(1)
# required_users :integer default(1)
#
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
id: 1
two:
id: 2
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html

View File

@ -1,9 +1,9 @@
# == Schema Information
# Schema version: 20090102171850
# Schema version: 20090120184410
#
# Table name: users
#
# id :integer(4) not null, primary key
# id :integer not null, primary key
# nick :string(255) default(""), not null
# password_hash :string(255) default(""), not null
# password_salt :string(255) default(""), not null
@ -11,7 +11,6 @@
# last_name :string(255) default(""), not null
# email :string(255) default(""), not null
# phone :string(255)
# address :string(255)
# created_on :datetime not null
# reset_password_token :string(255)
# reset_password_expires :datetime
@ -20,17 +19,16 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
admin:
id: 1
nick: admin
first_name: Anton
last_name: Admininistrator
email: admin@foo.test
#TODO: password can't loaded directyl to the database
#password_hash:
#password_salt:
password_hash: a3c77e64311ad37161e582b28737d1e420962538
password_salt: LNpP/lca
test:
id: 2
nick: test
first_name: Tim
last_name: Tester
email: test@foo.test
password_hash: 5549cd54032a72435037893b02d95ebef13cdc57
password_salt: DxnbIF1h

View File

@ -1,7 +0,0 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
# one:
# column: value
#
# two:
# column: value