This commit is contained in:
Julius 2013-10-03 10:47:05 +02:00
commit dd54cdce7a
13 changed files with 209 additions and 151 deletions

View File

@ -26,7 +26,7 @@ class ApplicationController < ActionController::Base
def deny_access
session[:return_to] = request.original_url
redirect_to login_url, :alert => 'Access denied!'
redirect_to login_url, :alert => I18n.t('application.controller.error_denied')
end
private
@ -37,7 +37,7 @@ class ApplicationController < ActionController::Base
# No user at all: redirect to login page.
session[:user_id] = nil
session[:return_to] = request.original_url
redirect_to login_url, :alert => 'Authentication required!'
redirect_to login_url, :alert => I18n.t('application.controller.error_authn')
else
# We have an authenticated user, now check role...
# Roles gets the user through his memberships.
@ -83,7 +83,7 @@ class ApplicationController < ActionController::Base
def authenticate_membership_or_admin
@group = Group.find(params[:id])
unless @group.member?(@current_user) or @current_user.role_admin?
redirect_to root_path, alert: "Diese Aktion ist nur für Mitglieder der Gruppe erlaubt!"
redirect_to root_path, alert: I18n.t('application.controller.error_members_only')
end
end

View File

@ -10,7 +10,7 @@ class Finance::BalancingController < Finance::BaseController
flash.now.alert = t('finance.balancing.new.alert') if @order.closed?
@comments = @order.comments
@articles = @order.order_articles.ordered.includes(:article, :article_price,
@articles = @order.order_articles.ordered_or_member.includes(:article, :article_price,
group_order_articles: {group_order: :ordergroup})
sort_param = params['sort'] || 'name'

View File

@ -34,7 +34,7 @@ class Finance::FinancialTransactionsController < ApplicationController
@financial_transaction = FinancialTransaction.new(params[:financial_transaction])
@financial_transaction.user = current_user
@financial_transaction.add_transaction!
redirect_to finance_ordergroup_transactions_url(@ordergroup), notice: t('finance.financial_transactions.create.notice')
redirect_to finance_ordergroup_transactions_url(@ordergroup), notice: I18n.t('finance.financial_transactions.controller.create.notice')
rescue ActiveRecord::RecordInvalid => error
flash.now[:alert] = error.message
render :action => :new
@ -44,16 +44,16 @@ class Finance::FinancialTransactionsController < ApplicationController
end
def create_collection
raise "Notiz wird benötigt!" if params[:note].blank?
raise I18n.t('finance.financial_transactions.controller.create_collection.error_note_required') if params[:note].blank?
params[:financial_transactions].each do |trans|
# ignore empty amount fields ...
unless trans[:amount].blank?
Ordergroup.find(trans[:ordergroup_id]).add_financial_transaction!(trans[:amount], params[:note], @current_user)
end
end
redirect_to finance_ordergroups_url, notice: t('finance.create_collection.create.notice')
redirect_to finance_ordergroups_url, notice: I18n.t('finance.financial_transactions.controller.create_collection.notice')
rescue => error
redirect_to finance_new_transaction_collection_url, alert: t('finance.create_collection.create.alert', error: error.to_s)
redirect_to finance_new_transaction_collection_url, alert: I18n.t('finance.financial_transactions.controller.create_collection.alert', error: error.to_s)
end
protected

View File

@ -12,7 +12,8 @@ class OrderArticle < ActiveRecord::Base
validate :article_and_price_exist
validates_uniqueness_of :article_id, scope: :order_id
scope :ordered, :conditions => "units_to_order >= 1"
scope :ordered, :conditions => "units_to_order > 0"
scope :ordered_or_member, -> { includes(:group_order_articles).where("units_to_order > 0 OR group_order_articles.result > 0") }
before_create :init_from_balancing
after_destroy :update_ordergroup_prices

View File

@ -5,21 +5,19 @@
$('#stock_changes tr').removeClass('success');
var quantity = w.prompt('<%= j(t('.how_many_units', :unit => @stock_change.stock_article.unit, :name => @stock_change.stock_article.name)) %>');
if(null === quantity) {
return false;
}
var stock_change = $(
'<%= j(render(:partial => 'stock_change', :locals => {:stock_change => @stock_change})) %>'
).addClass('success');
enablePriceTooltips(stock_change);
$('input.stock-change-quantity', stock_change).val(quantity);
$('#stock_changes').append(stock_change);
mark_article_for_delivery(<%= @stock_change.stock_article.id %>);
updateSort('#stock_changes');
var quantity = w.prompt('<%= j(t('.how_many_units', :unit => @stock_change.stock_article.unit, :name => @stock_change.stock_article.name)) %>'); <%# how to properly escape here? %>
if(null === quantity) {
stock_change.remove();
mark_article_for_delivery(<%= @stock_change.stock_article.id %>);
return false;
}
$('input.stock-change-quantity', stock_change).val(quantity);
})(window);

View File

@ -4,4 +4,4 @@
= form.hidden_field :group_id
= form.input :email
= form.submit t('.action')
= link_to t('.back'), :back
= link_to t('ui.or_cancel'), :back

View File

@ -212,6 +212,11 @@ de:
workgroups:
members: Mitglieder
name: Name
application:
controller:
error_authn:
error_denied:
error_members_only: Diese Aktion ist nur für Mitglieder der Gruppe erlaubt!
article_categories:
create:
notice: Die Kategorie wurde gespeichert
@ -644,11 +649,13 @@ de:
create:
notice: Rechnung wurde erstellt.
financial_transactions:
create:
notice: Die Transaktion wurde gespeichert.
create_collection:
alert: ! 'Ein Fehler ist aufgetreten: %{error}'
notice: Alle Transaktionen wurden gespeichert.
controller:
create:
notice: Die Transaktion wurde gespeichert.
create_collection:
alert: ! 'Ein Fehler ist aufgetreten: %{error}'
error_note_required: Notiz wird benötigt!
notice: Alle Transaktionen wurden gespeichert.
index:
balance: ! 'Kontostand: %{balance}'
last_updated_at: (zuletzt aktualisiert vor %{when})
@ -971,7 +978,6 @@ de:
title: Person einladen
new:
action: Einlading abschicken
back: oder zurück
body: <p>Hier kannst du eine Person in die Gruppe <b>%{group}</b> einladen, die noch nicht Mitglied der Foodcoop ist.</p>
success: Benutzerin wurde erfolgreich eingeladen.
layouts:

View File

@ -212,6 +212,11 @@ en:
workgroups:
members: members
name: name
application:
controller:
error_authn: Authentication required!
error_denied: Access denied!
error_members_only: This action is only available to members of the group!
article_categories:
create:
notice: Category was stored
@ -430,7 +435,7 @@ en:
create:
notice: Delivery was created. Please dont forget to create invoice!
create_stock_article:
notice: The new stock article »%{name}« was saved.
notice: The new stock article "%{name}" was saved.
destroy:
notice: Delivery was deleted.
edit:
@ -478,7 +483,7 @@ en:
update:
notice: Delivery was updated.
update_stock_article:
notice: The stock article »%{name}« was updated.
notice: The stock article "%{name}" was updated.
documents:
order_by_articles:
filename: Order %{name}-%{date} - by articles
@ -648,11 +653,13 @@ en:
create:
notice: Invoice was created
financial_transactions:
create:
notice: The transaction was saved.
create_collection:
alert: ! 'An error occured: %{error}'
notice: All transactions were saved.
controller:
create:
notice: The transaction was saved.
create_collection:
alert: ! 'An error occured: %{error}'
error_note_required: Note is required!
notice: All transactions were saved.
index:
balance: ! 'Balance of account: %{balance}'
last_updated_at: (last updated %{when} ago)
@ -898,7 +905,7 @@ en:
warning: Warning, if you have less then %{threshold} of apple points, you are not allowed to place an order!
changes_saved: Changes saved.
index:
due_date_format: ! '%A %d %b'
due_date_format: ! '%A %d %B'
messages:
title: Newest Messages
view_all: See all messages
@ -975,7 +982,6 @@ en:
title: Invite person
new:
action: Send invite
back: or go back
body: <p>Here you can add a person to the group <b>%{group}</b>, who is not yet a member of the foodcoop.</p>
success: User was invited successfully.
layouts:
@ -1313,7 +1319,7 @@ en:
prices: Prices (net/FC)
select_all: Select all
stockit: In stock
supplier: Supplier
supplier: Producer
title: Article
unit_quantity: Unit quantity
index:
@ -1395,7 +1401,7 @@ en:
notice: Page was created
cshow:
error_noexist: Page doesnt exist!
redirect_notice: Redirected from %{page} ..
redirect_notice: Redirected from %{page} ...
destroy:
notice: The page '%{page}' and all subpages have been deleted successfully.
edit:
@ -1536,7 +1542,7 @@ en:
message:
private: Message doesnt show in Foodsoft mail inbox
order_article:
units_to_order: If you change the total amount of delivered units, you also have to change individual group amounts by clicking on the article name. They will not be automatically recalculated and otherwise ordergroups will be accounted for undelivered articles!
units_to_order: If you change the total amount of delivered units, you also have to change individual group amounts by clicking on the article name. They will not be automatically recalculated and so ordergroups may be accounted for articles that were not delivered!
update_current_price: Also update the price of the current order
stock_article:
copy_stock_article:
@ -1866,7 +1872,7 @@ en:
title: Show task
update:
notice: Task has been updated
notice_converted: Task has been updated and was converted to a regular task
notice_converted: Task has been updated and was converted to a non-repeating task.
user:
more: Nothing to do? %{tasks_link} are tasks for sure.
tasks_link: Here

View File

@ -212,6 +212,11 @@ fr:
workgroups:
members: membres
name: nom
application:
controller:
error_authn:
error_denied:
error_members_only:
article_categories:
create:
notice: La catégorie a bien été définie.
@ -655,11 +660,13 @@ fr:
create:
notice: La facture a bien été définie.
financial_transactions:
create:
notice: La transaction a été sauvegardée.
create_collection:
alert: ! 'Une erreur s''est produite: %{error}'
notice: Les transactions ont été sauvegardées.
controller:
create:
notice: La transaction a été sauvegardée.
create_collection:
alert: ! 'Une erreur s''est produite: %{error}'
error_note_required:
notice: Les transactions ont été sauvegardées.
index:
balance: ! 'Solde: %{balance}'
last_updated_at: (dernière mise à jour il y a %{when})
@ -994,7 +1001,6 @@ fr:
title: Engrainer une personne
new:
action: Engrainer!
back: ou revenir en arrière
body: <p>Sur cette page, tu peux engrainer une personne qui ne fait pas encore partie de la Boufcoop à rejoindre la cellule <b>%{group}</b>
success: La_le membre a été engrainéE avec succès!
layouts:
@ -1288,7 +1294,7 @@ fr:
article_count: ! 'Articles commandés:'
name: Nom
prices: Prix brut/net
prices_sum: Totaux (des prix bruts/nets)
prices_sum: ! 'Totaux (des prix bruts/nets):'
unit_quantity: Unités par lots x Lots
units_full: Lots complet
units_ordered: Unités commandées
@ -1536,7 +1542,7 @@ fr:
message:
private: Le message n'apparaîtra pas dans la boîte de réception du Foodsoft
order_article:
units_to_order: Nombre de lots livrés
units_to_order:
update_current_price: Modifie aussi le prix des commandes en cours
stock_article:
copy_stock_article:

View File

@ -212,6 +212,11 @@ nl:
workgroups:
members: leden
name: naam
application:
controller:
error_authn: Inloggen vereist.
error_denied: Geen toegang.
error_members_only: Deze actie is alleen beschikbaar voor leden van de groep!
article_categories:
create:
notice: Categorie is opgeslagen
@ -428,11 +433,11 @@ nl:
add_stock_change:
how_many_units:
create:
notice:
notice: Levering is aangemaakt. Vergeet niet een factuur te maken!
create_stock_article:
notice:
notice: Nieuw voorraadsartikel "%{name}" gemaakt.
destroy:
notice:
notice: Levering is verwijdered.
edit:
title:
form:
@ -476,7 +481,7 @@ nl:
remove_article:
suppliers_overview:
update:
notice:
notice: Levering is bijgewerkt.
update_stock_article:
notice:
documents:
@ -645,11 +650,13 @@ nl:
create:
notice: Rekening is gemaakt
financial_transactions:
create:
notice: De transactie is opgeslagen.
create_collection:
alert:
notice: Alle transacties zijn opgeslagen.
controller:
create:
notice: De transactie is opgeslagen.
create_collection:
alert:
error_note_required: Notitie ontbreekt.
notice: Alle transacties zijn opgeslagen.
index:
balance: ! 'Tegoed: %{balance}'
last_updated_at: (laatst bijgewerkt %{when} geleden)
@ -668,8 +675,8 @@ nl:
sidebar:
title:
ordergroup:
remove:
remove_group:
remove: Verwijderen
remove_group: Huishouden verwijderen
transactions:
amount: Bedrag
date: Datum
@ -856,7 +863,7 @@ nl:
title: Lopende bestellingen
update:
error_general:
error_stale:
error_stale: In de tussentijd heeft iemand anders ook bestelt, daarom kon je bestelling niet opgeslagen worden. Sorry!
notice: De bestelling is opgeslagen.
helpers:
application:
@ -890,19 +897,19 @@ nl:
home:
apple_bar:
desc:
more_info:
more_info: Meer informatie
points:
warning:
changes_saved: Wijzigingen opgeslagen.
index:
due_date_format:
due_date_format: ! '%A %d %B'
messages:
title:
view_all:
my_ordergroup:
funds:
last_update:
title:
funds: ! '| Beschikbaar tegoed:'
last_update: Laatst gewijzigd %{when} geleden
title: Mijn huishouden
transactions:
amount: Bedrag
note: Notitie
@ -913,13 +920,13 @@ nl:
ordergroup:
title:
tasks_move:
action:
desc:
title:
action: Taken op je nemen/annuleren
desc: Je bent voor de volgende taken verantwoordelijk.
title: Taken op je nemen
tasks_open:
action:
desc:
title:
action: open taken
desc: Er zijn %{size}
title: open taken
title: Beginpagina
your_tasks: Jouw taken
no_ordergroups: Jammergenoeg ben je niet aangesloten bij een huishouden.
@ -946,7 +953,7 @@ nl:
admin:
finances:
accounts: Tegoeden bijwerken
settle:
settle: Bestelling afrekenen
title: Financiën
foodcoop: Foodcoop
members: Leden
@ -972,7 +979,6 @@ nl:
title:
new:
action:
back:
body:
success:
layouts:
@ -1052,16 +1058,34 @@ nl:
Vriendelijke groet van %{foodcoop}.'
reset_password:
subject:
text:
subject: Nieuw wachtwoord voor %{username}
text: ! 'Beste %{user},
Jij (of iemand anders) heeft een nieuw wachtwoord aangevraagd voor het foodcoop ordersysteem.
Ga naar de volgende pagina om een nieuw wachtwoord in te voeren: %{link}
Dit kan slechts éenmaal gedaan worden, en op zijn laatst op %{expires}.
Wanneer je je wachtwoord niet wilt veranderen, hoef je niets te doen; dan blijft je huidige wachtwoord geldig.
Groeten van je foodcoop!'
upcoming_tasks:
nextweek:
subject:
text0:
text1:
nextweek: ! 'Taken voor komende week:'
subject: Er is een taak te doen!
text0: ! 'Beste %{user},
Je bent opgegeven voor "%{task}". Deze taak is morgen te vervullen (%{when})!'
text1: ! 'Mijn taken: %{user_tasks_url}
Groeten van %{foodcoop}.'
messages:
create:
notice:
notice: Bericht is opgeslagen en wordt verzonden.
index:
new:
title:
@ -1078,9 +1102,9 @@ nl:
subscribe:
subscribe_msg:
wiki:
no_user_found:
search:
search_user:
no_user_found: Geen gebruiker gevonden
search: Zoeken ...
search_user: Gebruiker zoeken
title:
show:
all_messages:
@ -1091,15 +1115,15 @@ nl:
title:
model:
delivery:
each_stock_article_must_be_unique:
each_stock_article_must_be_unique: In een levering mag ieder voorraadsartikel maar een keer voorkomen.
membership:
no_admin_delete:
no_admin_delete: Lidmaatschap kan niet beeindigd worden. Je bent de laatste administrator.
order_article:
error_price:
error_price: moet ingevuld worden en een huidige prijs hebben
page:
redirect:
redirect: Doorverwijzing naar [[%{title}]]...
user:
no_ordergroup:
no_ordergroup: geen huishouden
navigation:
admin:
home: Overzicht
@ -1187,46 +1211,46 @@ nl:
delimiter:
ordergroups:
edit:
title:
title: Huidhouden bewerken
index:
title:
title: Huishoudens
model:
error_single_group:
invalid_balance:
error_single_group: ! '%{user} behoort al tot een ander huishouden'
invalid_balance: is geen geldig nummer
orders:
articles:
article_count:
name:
prices:
prices_sum:
unit_quantity:
units_full:
units_ordered:
article_count: ! 'Bestelde artikelen:'
name: Naam
prices: Netto/bruto prijs
prices_sum: ! 'Totaal (netto/bruto prijs):'
unit_quantity: Groothandelseenheid
units_full: Volle eenheden
units_ordered: Bestelde eenheden
create:
notice:
notice: De bestelling is aangemaakt.
edit:
title:
title: Bestelling aanpassen
fax:
amount:
articles:
customer_number:
delivery_day:
heading:
name:
number:
to_address:
amount: Aantal
articles: Artikelen
customer_number: Klantnummer
delivery_day: Bezorgdag
heading: Bestelling voor %{name}
name: Naam
number: Nummer
to_address: Verzendadres
finish:
notice: De bestelling is gesloten.
form:
ignore_warnings:
name:
note:
origin:
prices:
select_all:
stockit:
supplier:
title:
ignore_warnings: Waarschuwingen negeren
name: Naam
note: Notitie
origin: Herkomst
prices: Prijs (netto/FC)
select_all: Alles selecteren
stockit: Beschikbaar
supplier: Producent
title: Artikel
unit_quantity:
index:
action_end:
@ -1244,7 +1268,7 @@ nl:
error_closed: Bestelling was al afgerekend
error_nosel:
error_starts_before_ends:
notice_close:
notice_close: ! 'Bestelling: %{name}, tot %{ends}'
stock: Voorraad
warning_ordered:
warning_ordered_stock:
@ -1288,7 +1312,7 @@ nl:
finished: gesloten
open: lopend
update:
notice:
notice: De bestelling is bijgewerkt.
pages:
all:
new_page:
@ -1302,12 +1326,12 @@ nl:
body:
title_toc:
create:
notice:
notice: Pagina is gemaakt.
cshow:
error_noexist:
redirect_notice:
redirect_notice: Doorverwezen van %{page} ...
destroy:
notice:
notice: De pagina '%{page}' en alle subpagina's zijn verwijderd.
edit:
title:
error_stale_object:
@ -1351,7 +1375,7 @@ nl:
versions:
title:
update:
notice:
notice: Pagina is bijgewerkt.
version:
author:
date_format:
@ -1394,11 +1418,11 @@ nl:
address: Adres
apple_limit:
contact: Contact
deactivated:
description:
deactivated: inactief
description: Beschrijving
members: Leden
no_weekly_job:
weekly_job:
no_weekly_job: geen wekelijkse taak ingesteld
weekly_job: wekelijkse taak
group_form_fields:
search: Zoeken ...
search_user: Gebruiker zoeken
@ -1407,8 +1431,8 @@ nl:
loginInfo:
edit_profile: Profiel aanpassen
feedback:
desc:
title:
desc: Fout gevonden? Opmerking? Idee?
title: Feedback
help: Help
homepage_title: Foodcoop startpagina bezoeken
logout: Uitloggen
@ -1436,7 +1460,7 @@ nl:
total_sum: Totaalsom
who_ordered: Wie heeft besteld?
workgroup_members:
title:
title: Groepsleden
simple_form:
error_notification:
default_message:
@ -1550,7 +1574,7 @@ nl:
address:
contact_person:
customer_number:
delivery_days:
delivery_days: Bezorgdagen
email:
fax:
is_subscribed:
@ -1601,7 +1625,7 @@ nl:
'yes': Ja
stock_takings:
create:
notice:
notice: Inventarisatie is aangelegd.
edit:
title:
index:
@ -1629,12 +1653,12 @@ nl:
date:
note:
update:
notice:
notice: Inventarisatie is bijgewerkt.
stockit:
check:
not_empty:
destroy:
notice:
notice: Artikel %{name} is verwijdered.
edit:
title:
form:
@ -1674,14 +1698,14 @@ nl:
search_text:
title:
stock_create:
notice:
notice: Voorraadsartikel is opgeslagen.
stock_update:
notice:
notice: Voorraadsartikel is bijgewerkt.
suppliers:
create:
notice:
notice: Leverancier is aangemaakt.
destroy:
notice:
notice: Leverancier is verwijderd
edit:
title:
index:
@ -1707,7 +1731,7 @@ nl:
new_delivery:
show_deliveries:
update:
notice:
notice: Leverancier is bijgewerkt
support:
array:
last_word_connector:
@ -1715,7 +1739,7 @@ nl:
words_connector:
tasks:
accept:
notice:
notice: Je hebt de taak geaccepteerd
archive:
title:
archive_tasks:
@ -1724,9 +1748,9 @@ nl:
task_format:
who:
create:
notice:
notice: Taak is aangemaakt
destroy:
notice:
notice: Taak is verwijderd
edit:
title:
warning_periodic:
@ -1764,7 +1788,7 @@ nl:
title:
repeated:
set_done:
notice:
notice: De status van de taak is aangepast
show:
accept_task:
confirm_delete_group:
@ -1775,8 +1799,8 @@ nl:
reject_task:
title:
update:
notice:
notice_converted:
notice: Taak is bijgewerkt
notice_converted: Taak is bijgewerkt en omgezet naar een eenmalige taak.
user:
more:
tasks_link:

View File

@ -5,12 +5,12 @@ namespace :foodsoft do
task :notify_upcoming_tasks => :environment do
tasks = Task.where(done: false, due_date: 1.day.from_now.to_date)
for task in tasks
say "Send notifications for #{task.name} to .."
rake_say "Send notifications for #{task.name} to .."
for user in task.users
begin
Mailer.upcoming_tasks(user, task).deliver if user.settings.notify['upcoming_tasks'] == 1
rescue
say "deliver aborted for #{user.email}.."
rake_say "deliver aborted for #{user.email}.."
end
end
end
@ -27,7 +27,7 @@ namespace :foodsoft do
begin
Mailer.not_enough_users_assigned(task, user).deliver
rescue
say "deliver aborted for #{user.email}"
rake_say "deliver aborted for #{user.email}"
end
end
end
@ -49,6 +49,6 @@ namespace :foodsoft do
end
# Helper
def say(message)
def rake_say(message)
puts message unless Rake.application.options.silent
end

View File

@ -8,7 +8,7 @@ namespace :multicoops do
task :run => :environment do
task_to_run = ENV['TASK']
FoodsoftConfig.each_coop do |coop|
say "Run '#{task_to_run}' for #{coop}"
rake_say "Run '#{task_to_run}' for #{coop}"
Rake::Task[task_to_run].execute
end
end
@ -17,7 +17,7 @@ namespace :multicoops do
task :run_single => :environment do
task_to_run = ENV['TASK']
FoodsoftConfig.select_foodcoop ENV['FOODCOOP']
say "Run '#{task_to_run}' for #{ENV['FOODCOOP']}"
rake_say "Run '#{task_to_run}' for #{ENV['FOODCOOP']}"
Rake::Task[task_to_run].execute
end
@ -25,6 +25,6 @@ end
# Helper
def say(message)
puts message unless Rake.application.options.silent
def rake_say(message)
puts message unless Rake.application.options.silent
end

View File

@ -103,6 +103,23 @@ describe 'settling an order', :type => :feature do
expect(GroupOrderArticle.exists?(goa1.id)).to be_false
end
it 'keeps product when amount is set to zero' do
within("#order_article_#{oa.id}") do
click_link I18n.t('ui.edit')
end
within("#edit_order_article_#{oa.id}") do
fill_in :order_article_units_to_order, :with => 0
find('input[type="submit"]').click
end
expect(page).to have_selector("#order_article_#{oa.id}")
# make sure it still works after reloading
visit new_finance_order_path(order_id: order.id)
expect(page).to have_selector("#order_article_#{oa.id}")
expect(OrderArticle.exists?(oa.id)).to be_true
oa.reload
expect(oa.units_to_order).to eq(0)
end
end
end