Refactoring of articles and article_categories. articles are now a nested resource of supplier.

This commit is contained in:
Benjamin Meichsner 2009-01-16 16:19:26 +01:00
parent b38025869a
commit 936e6ef69a
36 changed files with 597 additions and 589 deletions

View file

@ -151,4 +151,8 @@ class ApplicationController < ActionController::Base
call_rake :send_emails unless Message.pending.empty?
end
# Get supplier in nested resources
def find_supplier
@supplier = Supplier.find(params[:supplier_id]) if params[:supplier_id]
end
end

View file

@ -0,0 +1,68 @@
class ArticleCategoriesController < ApplicationController
before_filter :authenticate_article_meta
def new
@article_category = ArticleCategory.new
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/form'
page['category_form'].show
end
end
def edit
@article_category = ArticleCategory.find(params[:id])
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/form'
page['category_form'].show
end
end
def create
@article_category = ArticleCategory.new(params[:article_category])
if @article_category.save
render :update do |page|
page['category_form'].hide
page['category_list'].replace_html :partial => 'article_categories/list'
page['category_'+@article_category.id.to_s].visual_effect(:highlight,
:duration => 2)
end
else
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/form'
end
end
end
def update
@article_category = ArticleCategory.find(params[:id])
if @article_category.update_attributes(params[:article_category])
render :update do |page|
page['category_form'].hide
page['category_list'].replace_html :partial => 'article_categories/list'
page['category_'+@article_category.id.to_s].visual_effect(:highlight,
:duration => 2)
end
else
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/form'
end
end
end
def destroy
@article_category = ArticleCategory.find(params[:id])
@article_category.destroy
#id = @article_category.id.to_s #save the id before destroying the object
if @article_category.destroy
render :update do |page|
page['category_'+@article_category.id].visual_effect :drop_out
end
end
end
end

View file

@ -1,26 +1,7 @@
class ArticlesController < ApplicationController
before_filter :authenticate_article_meta
verify :method => :post,
:only => [ :destroyArticle, :createArticle, :updateArticle,
:update_all, :createArticlesFromFile, :update_selected_articles ],
:redirect_to => { :action => :list }
# messages
ERROR_NO_SELECTED_ARTICLES = 'Du hast keine Artikel ausgewählt'
MSG_ALL_CHECKED_DESTROYED = 'Alle gewählten Artikel wurden gelöscht'
MSG_ALL_CHECKED_UNAVAILABLE = 'Alle gewählten Artikel wurden auf "nicht verfügbar" gesetzt'
MSG_ALL_CHECKED_AVAILABLE = 'Alle gewählten Artikel wurden auf "verfügbar" gesetzt'
ERROR_NO_SELECTED_ACTION = 'Keine Aktion ausgewählt!'
ERROR_UPDATE_ARTICLES = 'Ein Fehler ist aufgetreten: '
before_filter :authenticate_article_meta, :find_supplier
def index
@suppliers = Supplier.find(:all)
end
def list
if params[:id]
@supplier = Supplier.find(params[:id])
@suppliers = Supplier.find(:all)
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 500)
@per_page = params[:per_page].to_i
else
@ -58,25 +39,22 @@ class ArticlesController < ApplicationController
format.html # list.haml
format.js do
render :update do |page|
page.replace_html 'table', :partial => "list"
page.replace_html 'table', :partial => "articles"
end
end
end
else
redirect_to :action => 'index'
end
end
def newArticle
@supplier = Supplier.find(params[:supplier])
@article = Article.new(:supplier => @supplier, :tax => 7.0)
def new
@article = @supplier.articles.build(:tax => 7.0)
render :update do |page|
page["edit_article"].replace_html :partial => 'new'
page["edit_article"].show
end
end
def createArticle
def create
@article = Article.new(params[:article])
if @article.valid? and @article.save
render :update do |page|
@ -99,8 +77,9 @@ class ArticlesController < ApplicationController
end
# edit an article and its price
def editArticle
def edit
@article = Article.find(params[:id])
render :update do |page|
page["edit_article"].replace_html :partial => 'edit'
page["edit_article"].show
@ -109,8 +88,9 @@ class ArticlesController < ApplicationController
end
# Updates one Article and highlights the line if succeded
def updateArticle
def update
@article = Article.find(params[:id])
if @article.update_attributes(params[:article])
render :update do |page|
page["edit_article"].hide
@ -138,9 +118,10 @@ class ArticlesController < ApplicationController
end
# Deletes article from database. send error msg, if article is used in a current order
def destroyArticle
def destroy
@article = Article.find(params[:id])
@order = @article.inUse #if article is in an active Order, the Order will be returned
@order = @article.inUse # If article is in an active Order, the Order will be returned
if @order
render :update do |page|
page.insert_html :after, @article.id.to_s, :partial => 'destroyActiveArticle'
@ -155,7 +136,10 @@ class ArticlesController < ApplicationController
# Renders a form for editing all articles from a supplier
def edit_all
@supplier = Supplier.find(params[:id])
@articles = @supplier.articles.find :all,
:order => 'article_categories.name, articles.name',
:include => [:article_category]
end
# Updates all article of specific supplier
@ -164,14 +148,11 @@ class ArticlesController < ApplicationController
currentArticle = nil # used to find out which article caused a validation exception
begin
Article.transaction do
@supplier = Supplier.find(params[:supplier][:id]) if params[:supplier][:id]
unless params[:article].blank?
unless params[:articles].blank?
# Update other article attributes...
i = 0
for id in params[:article].keys
for id, attributes in params[:articles]
currentArticle = Article.find(id)
currentArticle.update_attributes!(params[:article].values[i])
i += 1
currentArticle.update_attributes!(attributes)
end
end
# delete articles
@ -181,118 +162,50 @@ class ArticlesController < ApplicationController
end
# Successfully done.
flash[:notice] = 'Alle Artikel und Preise wurden aktalisiert'
redirect_to :action => 'list', :id => @supplier
redirect_to supplier_articles_path(@supplier)
rescue => e
# An error has occurred, transaction has been rolled back.
if currentArticle
@failedArticle = currentArticle
flash[:error] = "Es trat ein Fehler beim Aktualisieren des Artikels '#{currentArticle.name}' auf: #{e.message}"
params[:sync] ? redirect_to(:action => "list", :id => @supplier) : render(:action => 'edit_all')
params[:sync] ? redirect_to(supplier_articles_path(@supplier)) : render(:action => 'edit_all')
else
flash[:error] = "Es trat ein Fehler beim Aktualisieren der Artikel auf: #{e.message}"
redirect_to :action => "index"
redirect_to supplier_articles_path(@supplier)
end
end
end
# makes different actions on selected articles
def update_selected_articles
@supplier = Supplier.find(params[:supplier])
articles = Array.new
begin
raise ERROR_NO_SELECTED_ARTICLES if params[:selected_articles].nil?
params[:selected_articles].each do |article|
articles << Article.find(article) # put selected articles in an array
end
def update_selected
raise 'Du hast keine Artikel ausgewählt' if params[:selected_articles].nil?
articles = Article.find(params[:selected_articles])
case params[:selected_action].to_s
case params[:selected_action]
when 'destroy'
articles.each {|a| a.destroy }
flash[:notice] = MSG_ALL_CHECKED_DESTROYED
flash[:notice] = 'Alle gewählten Artikel wurden gelöscht'
when 'setNotAvailable'
articles.each {|a| a.update_attribute(:availability, false) }
flash[:notice] = MSG_ALL_CHECKED_UNAVAILABLE
flash[:notice] = 'Alle gewählten Artikel wurden auf "nicht verfügbar" gesetzt'
when 'setAvailable'
articles.each {|a| a.update_attribute(:availability, true) }
flash[:notice] = MSG_ALL_CHECKED_AVAILABLE
flash[:notice] = 'Alle gewählten Artikel wurden auf "verfügbar" gesetzt'
else
flash[:error] = ERROR_NO_SELECTED_ACTION
flash[:error] = 'Keine Aktion ausgewählt!'
end
# action succeded
redirect_to :action => 'list', :id => @supplier
redirect_to supplier_articles_path(@supplier)
rescue => e
flash[:error] = ERROR_UPDATE_ARTICLES + e
redirect_to :action => 'list', :id => @supplier
end
end
#************** start article categories ************************
def newCategory
@article_category = ArticleCategory.new
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/new'
page['category_form'].show
end
end
def createCategory
@article_category = ArticleCategory.new(params[:article_category])
if @article_category.save
render :update do |page|
page['category_form'].hide
page['category_list'].replace_html :partial => 'article_categories/list'
page['category_'+@article_category.id.to_s].visual_effect(:highlight,
:duration => 2)
end
else
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/new'
end
end
end
def editCategory
@article_category = ArticleCategory.find(params[:id])
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/edit'
page['category_form'].show
end
end
def updateCategory
@article_category = ArticleCategory.find(params[:id])
if @article_category.update_attributes(params[:article_category])
render :update do |page|
page['category_form'].hide
page['category_list'].replace_html :partial => 'article_categories/list'
page['category_'+@article_category.id.to_s].visual_effect(:highlight,
:duration => 2)
end
else
render :update do |page|
page['category_form'].replace_html :partial => 'article_categories/edit'
end
end
end
def destroyCategory
@article_category = ArticleCategory.find(params[:id])
id = @article_category.id.to_s #save the id before destroying the object
if @article_category.destroy
render :update do |page|
page['category_'+id].visual_effect :drop_out
end
end
flash[:error] = 'Ein Fehler ist aufgetreten: ' + e
redirect_to supplier_articles_path(@supplier)
end
# lets start with parsing articles from uploaded file, yeah
# Renders the upload form
def upload_articles
def upload
end
# parses the articles from a csv and creates a form-table with the parsed data.
@ -301,7 +214,7 @@ class ArticlesController < ApplicationController
# the first line will be ignored.
# field-seperator: ";"
# text-seperator: ""
def parse_articles
def parse_upload
begin
@articles = Array.new
articles, outlisted_articles = FoodsoftFile::parse(params[:articles]["file"])
@ -320,44 +233,38 @@ class ArticlesController < ApplicationController
:tax => row[:tax])
# stop parsing, when an article isn't valid
unless article.valid?
raise article.errors.full_messages.join(", ") + _(" ..in line ") + (articles.index(row) + 2).to_s
raise article.errors.full_messages.join(", ") + " ..in line " + (articles.index(row) + 2).to_s
end
@articles << article
end
flash.now[:notice] = @articles.size.to_s + _(" articles are parsed successfully.")
flash.now[:notice] = @articles.size.to_s + " articles are parsed successfully."
rescue => e
flash[:error] = _("An error has occurred: ") + e.message
redirect_to :action => 'upload_articles'
flash[:error] = "An error has occurred: " + e.message
redirect_to upload_supplier_articles_path(@supplier)
end
end
# creates articles from form
def create_articles_from_file
@supplier = Supplier.find(params[:supplier][:id])
def create_from_upload
begin
Article.transaction do
i = 0
params[:article].each do
@article = Article.new(params[:article][i])
@article.supplier = @supplier
@article.save!
i += 1
for article_attributes in params[:articles]
@supplier.articles.create!(article_attributes)
end
end
# Successfully done.
flash[:notice] = _("The articles are saved successfully")
redirect_to :action => 'list', :id => @supplier
rescue => e
flash[:notice] = "The articles are saved successfully"
redirect_to supplier_articles_path(@supplier)
rescue => error
# An error has occurred, transaction has been rolled back.
flash[:error] = _("An error occured: ") + " #{e.message}"
redirect_to :action => 'upload_articles'
flash[:error] = "An error occured: #{error.message}"
redirect_to upload_supplier_articles_path(@supplier)
end
end
# renders a view to import articles in local database
#
def list_shared_articles
@supplier = Supplier.find(params[:id])
def shared
conditions = []
conditions << "supplier_id = #{@supplier.shared_supplier.id}"
# check for keywords
@ -374,8 +281,8 @@ class ArticlesController < ApplicationController
end
# fills a form whith values of the selected shared_article
def new_import
shared_article = SharedArticle.find(params[:id])
def import
shared_article = SharedArticle.find(params[:shared_article_id])
@article = Article.new(
:supplier_id => params[:supplier_id],
:name => shared_article.name,
@ -399,12 +306,12 @@ class ArticlesController < ApplicationController
# sync all articles with the external database
# renders a form with articles, which should be updated
def sync_articles
def sync
@supplier = Supplier.find(params[:id])
# check if there is an shared_supplier
unless @supplier.shared_supplier
flash[:error]= @supplier.name + _(" ist not assigned to an external database.")
redirect_to :action => "list", :id => @supplier
redirect_to supplier_articles_path(@supplier)
end
# sync articles against external database
@updated_articles, @outlisted_articles = @supplier.sync_all
@ -412,7 +319,7 @@ class ArticlesController < ApplicationController
@updated_articles.each {|a, b| a.shared_updated_on = a.shared_updated_on.to_formatted_s(:db)}
if @updated_articles.empty? && @outlisted_articles.empty?
flash[:notice] = _("The database is up to date.")
redirect_to :action => 'list', :id => @supplier
redirect_to supplier_articles_path(@supplier)
end
end
end

View file

@ -83,10 +83,4 @@ class DeliveriesController < ApplicationController
page.visual_effect(:DropOut, "stock_change_#{stock_change.id}")
end
end
protected
def find_supplier
@supplier = Supplier.find(params[:supplier_id]) if params[:supplier_id]
end
end

View file

@ -7,9 +7,8 @@ class SuppliersController < ApplicationController
MSG_SUPPLIER_CREATED = "Lieferant wurde erstellt"
def index
@supplier_column_names = ["Name", "Telefon", "Email", "Kundennummer"]
@supplier_columns = ["name", "phone", "email", "customer_number"]
@suppliers = Supplier.find :all
@suppliers = Supplier.all :order => 'name'
#@categories = ArticleCategory.all :order => 'name'
end
def show

View file

@ -58,11 +58,11 @@ module ApplicationHelper
return result
end
def sort_link_helper(text, param, per_page = 10)
def sort_link_helper(text, param, per_page = (@per_page || 10) )
key = param
key += "_reverse" if params[:sort] == param
options = {
:url => {:action => 'list', :params => params.merge({:sort => key, :page => nil, :per_page => per_page})},
:url => url_for(:params => params.merge({:sort => key, :page => nil, :per_page => per_page})),
:before => "Element.show('loader')",
:success => "Element.hide('loader')",
:method => :get
@ -102,4 +102,13 @@ module ApplicationHelper
def tab_is_active?(tab)
tab[:active].detect {|c| c == controller.controller_path }
end
def icon(name, options={})
icons = { :delete => { :file => 'b_drop.png', :alt => 'Löschen'},
:edit => { :file => 'b_edit.png', :alt => 'Bearbeiten'}}
options.merge!({:size => '16x16',:border => "0"})
options.merge!({:alt => icons[name][:alt]}) unless options[:alt]
image_tag icons[name][:file], options
end
end

View file

@ -0,0 +1,2 @@
module ArticleCategoriesHelper
end

View file

@ -4,4 +4,11 @@ module ArticlesHelper
def highlight_new(unequal_attributes, attribute)
unequal_attributes.detect {|a| a == attribute} ? "background-color: yellow" : ""
end
def row_classes(article)
classes = ""
classes += ' unavailable' if article.availability
classes += " just_updated" if @article.recently_updated && @article.availability
classes
end
end

View file

@ -1,7 +0,0 @@
<% remote_form_for :article_category, :url => { :action => 'updateCategory', :id => @article_category },
:before => "Element.show('loader')",
:success => "Element.hide('loader')" do |@f| %>
<%= render :partial => '/article_categories/form' %>
<br />
<%= submit_tag "Speichern" %> | <%= link_to_function("Abbrechen", "Element.hide('category_form')") %>
<% end %>

View file

@ -1,17 +1,24 @@
<%= error_messages_for 'article_category' %>
<% remote_form_for @article_category,
:before => "Element.show('loader')",
:success => "Element.hide('loader')" do |@f| %>
<!--[form:article_category]-->
<%= @f.error_messages %>
<table>
<tr>
<th>Name</th>
<th>Beschreibung</th>
</tr>
<tr>
<td><label for="article_category_name">
<%= @f.text_field 'name', :size => 20 %></label></td>
<td><label for="article_category_description">
<%= @f.text_field 'description', :size => 30 %></label></td>
<td>
<%= @f.text_field :name, :size => 20 %>
</td>
<td>
<%= @f.text_field :description, :size => 30 %>
</td>
</tr>
</tabel>
<!--[eoform:article_category]-->
</table>
<br />
<%= submit_tag "Speichern" %> | <%= link_to_function("Abbrechen", "Element.hide('category_form')") %>
<% end %>

View file

@ -4,19 +4,24 @@
<th>Beschreibung</th>
<th colspan="2"></th>
</tr>
<% for article_category in ArticleCategory.find(:all) %>
<tr class="<%= cycle("even","odd", :name => 'category') %>" id="category_<%= article_category.id %>">
<td><%=h article_category.name %></td>
<td><%=h article_category.description %></td>
<td><%= link_to_remote(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => 'Katgerie bearbeiten'),
:url => {:action => 'editCategory', :id => article_category},
<% for article_category in ArticleCategory.find(:all) -%>
<tr class="<%= cycle("even","odd", :name => 'category') -%>" id="category_<%= article_category.id -%>">
<td><%=h article_category.name -%></td>
<td><%=h article_category.description -%></td>
<td><%= link_to_remote icon(:edit),
:url => edit_article_category_path(article_category),
:method => :get,
:before => "Element.show('loader')",
:success => "Element.hide('loader')" ) %></td>
<td><%= link_to_remote(image_tag('b_drop.png', :size => "16x16", :border => "0", :alt => 'Kategorie löschen'), :url => {:action => 'destroyCategory', :id => article_category }, :confirm => 'Are you sure?' )%></td>
:success => "Element.hide('loader')" -%></td>
<td><%= link_to_remote icon(:delete),
:url => article_category,
:method => :delete,
:confirm => 'Are you sure?' -%></td>
</tr>
<% end %>
<% end -%>
</table>
<br />
<%= link_to_remote('Neue Kategorie', :url => {:action => :newCategory},
<%= link_to_remote 'Neue Kategorie', :url => new_article_category_path,
:method => :get,
:before => "Element.show('loader')",
:success => "Element.hide('loader')") -%>
:success => "Element.hide('loader')" %>

View file

@ -1,7 +0,0 @@
<% remote_form_for :article_category, :url => { :action => 'createCategory', :id => @article_category },
:before => "Element.show('loader')",
:success => "Element.hide('loader')" do |@f| %>
<%= render :partial => '/article_categories/form' %>
<br />
<%= submit_tag "Speichern" %> | <%= link_to_function("Abbrechen", "Element.hide('category_form')") %>
<% end %>

View file

@ -1,27 +1,32 @@
<td>
<%= check_box_tag 'selected_articles[]', @article.id.to_s, false, {:id => "checkbox_#{@article.id.to_s}", :onclick => "checkRow('#{@article.id.to_s}')"} %>
<%= check_box_tag 'selected_articles[]', @article.id.to_s, false,
{:id => "checkbox_#{@article.id.to_s}", :onclick => "checkRow('#{@article.id.to_s}')"} %>
</td>
<td><%=h @article.name %></td>
<td><%= @article.origin %></td>
<td><%=h truncate(@article.article_category.name, 11) if @article.article_category%></td>
<td><%=h @article.unit %></td>
<td><%=h truncate(@article.note, 15) %></td>
<td><%= @article.unit_quantity %></td>
<td><%=h @article.name -%></td>
<td><%= @article.origin -%></td>
<td><%=h truncate(@article.article_category.name, :length => 11) if @article.article_category -%></td>
<td><%=h @article.unit -%></td>
<td><%=h truncate(@article.note, :length => 11) -%></td>
<td><%= @article.unit_quantity -%></td>
<td class="currency">
<acronym title="zuletzt geändert: <%= format_date(@article.updated_at) %>
| Brutto: <%= number_to_currency(@article.gross_price) %>">
<%= number_to_currency(@article.net_price) %>
<acronym title="zuletzt geändert: <%= format_date(@article.updated_at) -%>
| Brutto: <%= number_to_currency(@article.gross_price) -%>">
<%= number_to_currency(@article.net_price) -%>
</acronym>
</td>
<td><%= number_to_percentage(@article.tax) if @article.tax != 0 %></td>
<td><%= number_to_currency(@article.deposit) if @article.deposit != 0 %></td>
<td><%= link_to_remote(image_tag('b_edit.png', :size => "16x16", :border => 0, :alt => 'Artikel ändern', :onclick => "checkRow('#{@article.id.to_s}')"),
:url => {:action => 'editArticle', :id => @article },
<td><%= number_to_percentage(@article.tax) if @article.tax != 0 -%></td>
<td><%= number_to_currency(@article.deposit) if @article.deposit != 0 -%></td>
<td>
<%= link_to_remote icon(:edit, :onclick => "checkRow('#{@article.id.to_s}')"),
:url => edit_supplier_article_path(@supplier, @article),
:method => :get,
:before => "Element.show('loader')",
:success => "Element.hide('loader')") %>
<%= link_to_remote(image_tag('b_drop.png', :size => "16x16", :border => 0, :alt => 'Artikel löschen', :onclick => "checkRow('#{@article.id.to_s}')"),
:url => { :action => 'destroyArticle', :id => @article },
:success => "Element.hide('loader')" %>
<%= link_to_remote icon(:delete, :onclick => "checkRow('#{@article.id.to_s}')"),
:url => [@supplier, @article],
:method => :delete,
:confirm => 'Bist du sicher?',
:before => "Element.show('loader')",
:success => "Element.hide('loader')")%></td>
:success => "Element.hide('loader')" %>
</td>

View file

@ -16,14 +16,14 @@
%tr
%th
%th[sort_td_class_helper "name"]
= sort_link_helper _("Name"), "name", @supplier.id
= sort_link_helper _("Name"), "name"
%th
%th[sort_td_class_helper "category"]
= sort_link_helper _("Category"), "category", @supplier.id
= sort_link_helper _("Category"), "category"
%th[sort_td_class_helper "unit"]
= sort_link_helper _("Unit"), "unit", @supplier.id
= sort_link_helper _("Unit"), "unit"
%th[sort_td_class_helper "note"]
= sort_link_helper _("Note"), "note", @supplier.id
= sort_link_helper _("Note"), "note"
%th{:style => "width: 4em;"}=_ 'UnitQu'
%th{:style => "width: 4em;"}=_ 'Price'
%th{:style => "width: 3.5em;"}=_ 'Tax'
@ -34,20 +34,19 @@
- if @total > 0
- for @article in @articles
%tr{ :class => cycle('even','odd') + (!@article.availability ? ' unavailable' : '') + ((@article.recently_updated && @article.availability) ? " just_updated" : ""), |
:id => @article.id, :onclick => "checkRow('#{@article.id.to_s}')"} |
%tr{ :class => cycle('even','odd') + row_classes(@article), :id => @article.id, :onclick => "checkRow('#{@article.id.to_s}')"}
= render :partial => 'article_row'
%tfoot
%tr
%td{:colspan => '10'}
%input{:type => 'checkbox', :name => 'checkall', :onclick => 'checkUncheckAll(this)'}/
%td{:colspan => '11'}
= check_box_tag :checkall, 1, false, :onclick => 'checkUncheckAll(this)'
%select{:name => "selected_action"}
%option{:value => '', :selected => 'selected'} Aktion wählen ...
%option{:value => "destroy", :onclick => "if (confirm('Willst Du wirklich alle gewählten Artikel löschen?')) { formSubmit(); }; return false;"} Artikel löschen
%option{:value => "setNotAvailable", :onclick => 'formSubmit();'} Artikel sind nicht mehr verfügbar
%option{:value => "setAvailable", :onclick => 'formSubmit();'} Artikel sind verfügbar
= hidden_field_tag 'supplier', @supplier.id
= hidden_field_tag 'supplier_id', @supplier.id
%p
= pagination_links_remote @articles, :params => {:sort => params[:sort]}

View file

@ -4,11 +4,4 @@
zuletzt aktualisiert am:
= format_time(@article.updated_at)
- form_remote_tag :url => { :action => 'updateArticle', :id => @article}, :html => {:id => "edit"}, |
:before => "Element.show('loader')", :success => "Element.hide('loader')" do |form| |
= render :partial => "form"
= submit_tag "Speichern"
|
= link_to_function "Abbrechen", "Element.hide('edit_article')"

View file

@ -0,0 +1,45 @@
- remote_form_for [@supplier, @article], :before => "Element.show('loader')", |
:success => "Element.hide('loader')" do |form| |
= form.error_messages
%p
%b Verfügbar?
= form.check_box :availability
%table{ :style => "width: 20em"}
%tr
%th Name
%th Herkunft
%th Hersteller
%th Einheit
%th Notiz
%th kategorie
%tbody
%tr
%td= form.text_field :name, :size => 15
%td= form.text_field :origin, :size => 5
%td= form.text_field :manufacturer, :size => 8
%td= form.text_field :unit, :size => 5
%td= form.text_field :note, :size => 15
%td= form.select :article_category_id, ArticleCategory.find(:all, :order => 'name').collect {|a| [ a.name, a.id ] }
%br/
%table{ :style=>"width:35em"}
%tr
%th Nettopreis
%th Gebindegröße
%th Bestellnummer
%th MwSt
%th Pfand
%tbody
%tr
%td= form.text_field :net_price, :size => 5
%td= form.text_field :unit_quantity, :size => 5
%td= form.text_field :order_number, :size => 10
%td= form.text_field :tax, :size => 5
%td= form.text_field :deposit, :size => 5
= form.hidden_field :shared_updated_on
= form.hidden_field :supplier_id
= submit_tag "Speichern"
|
= link_to_function "Abbrechen", "Element.hide('edit_article')"

View file

@ -1,69 +0,0 @@
<%= error_messages_for 'article' %>
<!--[form:article]-->
<p>
<b>Verfügbar?</b> <label for="article_availability"><%= check_box 'article', 'availability' %></label>
</p>
<table style="width: 20em">
<tr>
<th>Name</th>
<th>Herkunft</th>
<th>Herstellerin</th>
<th>Einheit</th>
<th>Notiz</th>
<th>Kategorie</th>
</tr>
<tbody>
<tr>
<td>
<label for="article_name"><%= text_field 'article', 'name', :size => 15 %></label>
</td>
<td>
<label for="article_origin"><%= text_field 'article', 'origin', :size => 5 %></label>
</td>
<td>
<label for="article_manufacturer"><%= text_field 'article', 'manufacturer', :size => 8 %></label>
</td>
<td>
<label for="article_unit"><%= text_field 'article', 'unit', :size => 5 %></label>
</td>
<td>
<label for="article_note"><%= text_field 'article', 'note', :size => 15 %></label>
</td>
<td>
<label for="article_article_category"><%= select('article', 'article_category_id', ArticleCategory.find(:all, :order => 'name').collect {|a| [ a.name, a.id ] }) %></label>
</td>
</tr>
</tbody>
</table>
<br />
<table style="width:35em">
<tr>
<th>netto Preis</th>
<th>Gebindegröße</th>
<th>Artikelnummer</th>
<th>Steuer</th>
<th>Pfand</th>
</tr>
<tbody>
<tr>
<td><label for="article_net_price">
<%= text_field 'article', 'net_price', :size => 5%></label></td>
<td><label for="article_unit_quantity">
<%= text_field 'article', 'unit_quantity', :size => 5%></label></td>
<td><label for="article_order_number">
<%= text_field 'article', 'order_number', :size => 10%></label></td>
<td><label for="article_tax">
<%= text_field 'article', 'tax', :size => 5%></label></td>
<td><label for="article_deposit">
<%= text_field 'article', 'deposit', :size => 5%></label></td>
</tr>
</tbody>
</table>
<%= hidden_field 'article', 'shared_updated_on' %>
<%= hidden_field 'article', 'supplier_id' %>
<!--[eoform:article]-->

View file

@ -21,5 +21,7 @@
%td= number_to_currency(article.price)
%td= article.unit
%td= article.unit_quantity
%td= link_to_remote 'importieren', :url => {:action => 'new_import', :id => article, :supplier_id => @supplier.id}
%td= link_to_remote 'importieren', |
:url => import_supplier_articles_path(@supplier, :shared_article_id => article.id), |
:method => :get |

View file

@ -1,5 +1,2 @@
%h3 Neuer Artikel
- form_remote_tag :url => { :action => 'createArticle'} do
= render :partial => 'articles/form'
= submit_tag "Speichern"
= link_to_function('Abbrechen', 'Element.hide("edit_article")')
= render :partial => 'form'

View file

@ -1,25 +1,26 @@
<h1>Alle Artikel von <%= @supplier.name %> bearbeiten</h1>
<div class="single_column" style="width:100%">
<div class="box_title">
<h2>
<div id="change_supplier">
<% form_tag do -%>
<select onchange="redirectTo(this)" style="font-size: 0.9em;margin-left:1em;">
<%= options_for_select(Supplier.find(:all).collect {|s| [ s.name, url_for(:action => "edit_all", :id => s)] }, url_for(:action => "edit_all", :id => @supplier.id)) %>
</select>
<%= select_tag :switch_supplier,
options_for_select( Supplier.all.collect {|s| [s.name, url_for(edit_all_supplier_articles_path(s))] },
url_for(edit_all_supplier_articles_path(@supplier)) ),
:onchange => "redirectTo(this)",
:style => "font-size: 0.9em;margin-left:1em;" %>
<% end %>
</div>
</h2>
<div class="box_title">
<h2></h2>
</div>
<div class="box column_content">
<div id="links"><%= link_to 'zurück zur Liste', :action => 'list', :id => @supplier.id %></div>
<div id="links"><%= link_to 'zurück zur Liste', supplier_articles_path(@supplier) -%></div>
<p>
<i>
Pflichtfelder sind: Name, Einheit, (netto) Preis und Bestellnummer.
</i>
</p>
<% form_tag(:action => 'update_all', :id => @supplier) do %>
<% form_tag(update_all_supplier_articles_path(@supplier)) do %>
<table id="articles_table" class="list">
<thead>
<tr>
@ -35,27 +36,29 @@
<th>Pfand</th>
</tr>
<tbody>
<% @supplier.articles.find(:all, :order => 'article_categories.name, articles.name', :include => [:article_category]).each do |@article| %>
<tr class="<%= cycle('even', 'odd') %>"<%= ' style="background-color: yellow"' if @failedArticle == @article %>>
<td colspan="2"><label for="article_availability"><%= check_box 'article[]', 'availability' %></label>
<label for="article_name"><%= text_field( 'article[]', 'name', :size => 0) %></label></td>
<td><label for="article_unit"><%= text_field 'article[]', 'unit', :size => 5 %></label></td>
<td><label for="article_net_price"><%= text_field 'article[]', 'net_price', :size => 4 %></label></td>
<td><label for="article_unit_quantity"><%= text_field 'article[]', 'unit_quantity', :size => 4 %></label></td>
<td><label for="article_order_number"><%= text_field 'article[]', 'order_number', :size => 6 %></label></td>
<td><label for="article_note"><%= text_field 'article[]', 'note', :size => 15 %></label></td>
<td><label for="article_article_category"><%= select('article[]', 'article_category_id', ArticleCategory.find(:all).collect {|a| [ a.name, a.id ] }, { :include_blank => true })%></label></td>
<td><label for="article_tax"><%= text_field 'article[]', 'tax', :size => 4 %></label></td>
<td><label for="article_deposit"><%= text_field 'article[]', 'deposit', :size => 4 %></label></td>
<% for article in @articles %>
<% fields_for 'articles[]', article do |form| %>
<tr class="<%= cycle('even', 'odd') %>"<%= ' style="background-color: yellow"' if @failedArticle == article %>>
<td colspan="2">
<%= form.check_box 'availability' -%>
<%= form.text_field 'name', :size => 0 -%>
</td>
<td><%= form.text_field 'unit', :size => 5 -%></td>
<td><%= form.text_field 'net_price', :size => 4 -%></td>
<td><%= form.text_field 'unit_quantity', :size => 4 -%></td>
<td><%= form.text_field 'order_number', :size => 6 -%></td>
<td><%= form.text_field 'note', :size => 15 -%></td>
<td><%= form.select 'article_category_id', ArticleCategory.find(:all).collect {|a| [ a.name, a.id ] }, { :include_blank => true } -%></td>
<td><%= form.text_field 'tax', :size => 4 -%></td>
<td><%= form.text_field 'deposit', :size => 4 -%></td>
</tr>
<% end %>
<% end %>
<!--[eoform:article]-->
</tbody>
</table><br />
<i>Achtung, alle Artikel werden aktualisiert!</i><br />
<%= hidden_field 'supplier', 'id' %>
<%= submit_tag 'Alle aktualisieren'%>
| <%= link_to 'Abbrechen', :action => 'list', :id => @supplier.id %>
<%= submit_tag 'Alle Artikel aktualisieren'%> | <%= link_to 'Abbrechen', supplier_articles_path(@supplier) %>
<% end %>
</div>
</div>

View file

@ -1,29 +1,73 @@
%h1 Manage die Artikeldatenbank
.left_column{:style => "width:44%"}
.box_title
%h2 Artikel anzeigen
.column_content
%p
%i
Hier kannst du Artikel anzeigen, ändern und neue erstellen
%br/
Wähle einen Lieferanten:
%ul
- @suppliers.each do |supplier|
%li
%b= link_to supplier.name, :action => "list", :id => supplier.id
(
= supplier.articles.count
Artikel )
%hr/
%p
%i
hier kannst du neue Artikel aus einer csv-Datei in die Datenbank
= link_to 'hochladen', :action => 'upload_articles'
- title "Artikel von #{@supplier.name}"
.right_column{:style => "width:53%"}
// import menu
- unless @supplier.shared_supplier.nil?
.menu{:style => 'width: 14em'}
%ul
%li
=_ 'External database'
%ul
%li= link_to_function _('search/import'), "Element.toggle('import')"
%li= link_to _('sync'), sync_supplier_articles_path(@supplier), :method => :post
#change_supplier{:style => "padding:0 0 0.5em 0.7em;"}
%span{:style => "float:left"}
=_ 'Change supplier:'
- form_tag do
= select_tag :switch_supplier, |
options_for_select( Supplier.all.collect {|s| [s.name, url_for(supplier_articles_path(s))] }, |
url_for(supplier_articles_path(@supplier)) ), |
:onchange => "redirectTo(this)", |
:style => "font-size: 0.9em;margin-left:1em;" |
- unless @supplier.shared_supplier.nil?
#import.single_column{:style => "display:none; clear:both"}
.box_title
%h2 Artikelkategorien
.column_content#categories
#category_form.box.edit_form{:style => "display:none;margin-bottom:1em;"}
#category_list= render :partial => 'article_categories/list'
%h2=_ 'Import articles'
.column_content
#search{:style => "padding-bottom:3em"}
- form_remote_tag :url => shared_supplier_articles_path(@supplier), |
:before => "Element.show('loader')", :success => "Element.hide('loader')", |
:method => :get do |
= text_field_tag :import_query, params['import_query'], :size => 10
= submit_tag _('Search articles')
- if @supplier.shared_supplier.lists
=_ "Search in following lists: "
- @supplier.shared_supplier.lists.each do |token, name|
= check_box_tag "lists[#{token}]", "1", true
= name
|
=_ "only regional:"
= check_box_tag "regional", "1", false
#search_results
// "import_search_results" will be rendered
= link_to_function _('Close'), "Element.hide('import')"
.single_column{:style => 'width:100%; clear:both'}
.box_title
.column_content
#links
%b= link_to_remote _('New article'), :url => new_supplier_article_path(@supplier), :before => "Element.show('loader')", :success => "Element.hide('loader')", :method => :get
|
= link_to _('Edit all'), edit_all_supplier_articles_path(@supplier)
|
= link_to _('Upload articles'), upload_supplier_articles_path(@supplier)
|
= link_to_if @current_user.role_orders?, _('Create order'), {:controller => 'orders', :action => 'new', :id => @supplier }
#article_filter
#article_search_form{:style=>"display:inline;"}
- form_remote_tag :url => supplier_articles_path(@supplier), |
:before => "Element.show('loader')", :success => "Element.hide('loader')", |
:method => :get do |
%label{:for => 'article_name'}=_ "Search in article name: "
= text_field_tag("query", params['query'], :size => 10 )
= submit_tag _('Search')
%form{ :action => url_for(update_selected_supplier_articles_path(@supplier)), :method => "post", :id => "articlesInListForm" }
#table= render :partial => 'articles'
%br/
= link_to _('Back'), :action => 'index'
#edit_article{:style => "display:none"}

View file

@ -1,70 +0,0 @@
%h1
=_ 'Articles from'
= @supplier.name
// import menu
- unless @supplier.shared_supplier.nil?
.menu{:style => 'width: 14em'}
%ul
%li
=_ 'External database'
%ul
%li= link_to_function _('search/import'), "Element.toggle('import')"
%li= link_to _('sync'), :action => 'sync_articles', :id => @supplier
#change_supplier{:style => "padding:0 0 0.5em 0.7em;"}
%span{:style => "float:left"}
=_ 'Change supplier:'
- form_tag do
%select{:onchange => "redirectTo(this)", :style => "font-size: 0.9em;margin-left:1em;"}
= options_for_select(@suppliers.collect {|s| [ s.name, url_for(:action => "list", :id => s)] }, url_for(:action => "list", :id => @supplier.id))
- unless @supplier.shared_supplier.nil?
#import.single_column{:style => "display:none; clear:both"}
.box_title
%h2=_ 'Import articles'
.column_content
#search{:style => "padding-bottom:3em"}
- form_remote_tag :url => {:action => "list_shared_articles", :id => @supplier}, :before => "Element.show('loader')", :success => "Element.hide('loader')" do
= text_field_tag :import_query, params['import_query'], :size => 10
= submit_tag _('Search articles')
- if @supplier.shared_supplier.lists
=_ "Search in following lists: "
- @supplier.shared_supplier.lists.each do |token, name|
= check_box_tag "lists[#{token}]", "1", true
= name
|
=_ "only regional:"
= check_box_tag "regional", "1", false
#search_results
// "import_search_results" will be rendered
= link_to_function _('Close'), "Element.hide('import')"
.single_column{:style => 'width:100%; clear:both'}
.box_title
.column_content
#links
%b= link_to_remote( _('New article'), :url => {:action => 'newArticle', :supplier => @supplier}, :before => "Element.show('loader')", :success => "Element.hide('loader')")
|
= link_to _('Edit all'), :action => 'edit_all', :id => @supplier
|
= link_to _('Upload articles'), :action => 'upload_articles'
|
= link_to_if @current_user.role_orders?, _('Create order'), {:controller => 'orders', :action => 'new', :id => @supplier }
#article_filter
#article_search_form{:style=>"display:inline;"}
- form_remote_tag :url => {:action => "list", :id => @supplier}, :before => "Element.show('loader')", :success => "Element.hide('loader')" do
%label{:for => 'article_name'}=_ "Search in article name: "
= text_field_tag("query", params['query'], :size => 10 )
= submit_tag _('Search')
%form{ :method => 'post', :action => url_for(:action => 'update_selected_articles', :only_path => true), :id => 'articlesInListForm'}
#table
= render :partial => 'list'
%br/
= link_to _('Back'), :action => 'index'
#edit_article{:style => "display:none"}

View file

@ -1,40 +0,0 @@
%h1=_ "Upload Articles"
%p
%i
=_ "Please check the parsed articles and choose a supplier at the end of page."
%br/
=_ "At the moment there is now checking of dublicate articles."
- form_tag(:action => 'create_articles_from_file') do
%table.list
%tr
%th=_ "Number"
%th=_ "Name"
%th=_ "Note"
%th=_ "Manufacturer"
%th=_ "Origin"
%th=_ "Unit"
%th=_ "Net price"
%th=_ "Tax"
%th=_ "Deposit"
%th=_ "Unit quantity"
%th=_ "Category"
- for @article in @articles
%tr{:class => cycle('even', 'odd')}
%td= text_field 'article[]', 'order_number', :size => 6
%td= text_field 'article[]', 'name', :size => 0
%td= text_field 'article[]', 'note', :size => 15
%td= text_field 'article[]', 'manufacturer', :size => 6
%td= text_field 'article[]', 'origin', :size => 6
%td= text_field 'article[]', 'unit', :size => 5
%td= text_field 'article[]', 'net_price', :size => 4
%td= text_field 'article[]', 'tax', :size => 4
%td= text_field 'article[]', 'deposit', :size => 4
%td= text_field 'article[]', 'unit_quantity', :size => 4
%td= select('article[]', 'article_category_id', ArticleCategory.find(:all).collect {|a| [ a.name, a.id ] })
%p
=_ "Choose a supplier:"
= select('supplier', 'id', Supplier.find(:all).collect {|s| [ s.name, s.id ] }, :selected => nil)
= submit_tag _("Save articles")
%p= link_to _("Back"), :action => 'upload_articles'

View file

@ -0,0 +1,40 @@
- title "#{@supplier.name} / Artikel hochladen"
%p
%i
=_ "Please check the parsed articles and choose a supplier at the end of page."
%br/
=_ "At the moment there is no checking of dublicate articles."
- form_tag(create_from_upload_supplier_articles_path(@supplier)) do
%table
%tr
%th=_ "Number"
%th=_ "Name"
%th=_ "Note"
%th=_ "Manufacturer"
%th=_ "Origin"
%th=_ "Unit"
%th=_ "Net price"
%th=_ "Tax"
%th=_ "Deposit"
%th=_ "Unit quantity"
%th=_ "Category"
- for article in @articles
- fields_for "articles[]", article do |form|
%tr{:class => cycle('even', 'odd')}
%td= form.text_field 'order_number', :size => 6
%td= form.text_field 'name', :size => 0
%td= form.text_field 'note', :size => 15
%td= form.text_field 'manufacturer', :size => 6
%td= form.text_field 'origin', :size => 6
%td= form.text_field 'unit', :size => 5
%td= form.text_field 'net_price', :size => 4
%td= form.text_field 'tax', :size => 4
%td= form.text_field 'deposit', :size => 4
%td= form.text_field 'unit_quantity', :size => 4
%td= form.select 'article_category_id', ArticleCategory.find(:all).collect {|a| [ a.name, a.id ] }
%p
= submit_tag "Save new Articles for #{@supplier.name}"
|
= link_to _("Back"), upload_supplier_articles_path(@supplier)

View file

@ -1,6 +1,6 @@
%h1 Artikel mit externer Datenbank synchronisieren
- form_tag :action => 'update_all', :id => @supplier, :sync => "1" do
- form_tag update_all_supplier_articles_path(@supplier, :sync => "1") do
%h2 Auslisten ...
%p
- unless @outlisted_articles.empty?

View file

@ -1,4 +1,4 @@
%h1=_ "Upload articles"
- title "#{@supplier.name} / Artikel hochladen"
%p
%i
=_ 'The file-type must be "csv" (textfile). Use a semicolon (";") to seperate the fields and double quotes ("Bananas...") for the text.'
@ -13,6 +13,6 @@
_("Scale quantity"), _("Scale price"), _("Category")].join(" | ") |
#uploadArticles.uploadForm
- form_for(:articles, :url => {:action => 'parse_articles'}, :html => { :multipart => true }) do |form|
- form_for(:articles, :url => parse_upload_supplier_articles_path(@supplier), :html => { :multipart => true }) do |form|
%p= form.file_field("file")
%p= submit_tag _("Upload articles")

View file

@ -23,11 +23,11 @@
{ :name => "Manage orders", :url => "/orders", :access? => (u.role_orders?) }
]
},
{ :name => "Articles", :url => "/articles", :active => ["articles", "suppliers", "deliveries"],
{ :name => "Articles", :url => "/suppliers", :active => ["articles", "suppliers", "deliveries", "article_categories"],
:access? => (u.role_article_meta? || u.role_suppliers?),
:subnav => [
{ :name => "Show articles", :url => "/articles/list" },
{ :name => "Categories", :url => "/articles" },
{ :name => "Show articles", :url => "/suppliers" },
{ :name => "Categories", :url => "/suppliers" },
{ :name => "Suppliers", :url => suppliers_path, :access? => (u.role_suppliers?) }
]
},

View 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>ArticleCategories: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
</head>
<body>
<p style="color: green"><%= flash[:notice] %></p>
<%= yield %>
</body>
</html>

View file

@ -1,6 +1,9 @@
- title "LieferantInnen"
- title "Artikeldatenbank"
- if @current_user.role_suppliers?
.left_column{:style => "width:50%"}
.box_title
%h2 Lieferanten
.column_content
%p
%i
Erstelle eine
@ -8,22 +11,24 @@
oder
= link_to 'importiere', shared_suppliers_suppliers_path
aus der externen ArtikelDatenbank.
.left_column{:style => "width:100%"}
.box_title
%h2 Übersicht
.column_content
%table
%table.list
%thead
%tr
- for column in @supplier_column_names
%th= column
%th Name
%th Telefon
%th KundenNr
%th
%tbody
- for supplier in @suppliers
%tr{:class => cycle('even','odd', :name => 'suppliers')}
- for column in @supplier_columns
%td
- if column == 'name'
= link_to supplier[column], supplier
- else
=h supplier[column]
%td= link_to 'Artikel anzeigen', :controller => 'articles', :action => 'list', :id => supplier
%td= link_to "<b>#{h(supplier.name)}</b> (#{supplier.articles.count})", supplier_articles_path(supplier)
%td=h supplier.phone
%td=h supplier.customer_number
%td= link_to "Anzeigen", supplier
.right_column{:style => "width:47%"}
.box_title
%h2 Artikelkategorien
.column_content#categories
#category_form.box.edit_form{:style => "display:none;margin-bottom:1em;"}
#category_list= render :partial => 'article_categories/list'

View file

@ -1,4 +1,5 @@
ActionController::Routing::Routes.draw do |map|
map.my_profile '/home/profile', :controller => 'home', :action => 'profile'
map.my_tasks '/home/tasks', :controller => 'tasks', :action => 'myTasks'
@ -19,7 +20,12 @@ ActionController::Routing::Routes.draw do |map|
map.resources :suppliers, :collection => { :shared_suppliers => :get } do |suppliers|
suppliers.resources :deliveries, :member => { :drop_stock_change => :post }
suppliers.resources :articles,
:collection => { :update_selected => :post, :edit_all => :get, :update_all => :post,
:upload => :get, :parse_upload => :post, :create_from_upload => :post,
:shared => :get, :import => :get, :sync => :post }
end
map.resources :article_categories
map.root :controller => 'home', :action => 'index'

View file

@ -252,7 +252,7 @@ div.edit_form {
position: fixed;
top: 23%;
left: 10em;
width: 50em;
width: 55em;
background: #FBFBFB;
padding: 3em;
padding-top: 1em;

View file

@ -252,7 +252,7 @@ div.edit_form {
position: fixed;
top: 23%;
left: 10em;
width: 50em;
width: 55em;
background: #FBFBFB;
padding: 3em;
padding-top: 1em;

View file

@ -33,24 +33,23 @@ h3.error {
#errorExplanation {
width: 40em;
border: 2px solid red;
padding: 7px;
padding-bottom: 12px;
margin-bottom: 20px;
background-color: #f0f0f0; }
color: #ed0606; }
#errorExplanation h2 {
color: #ed0606;
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
background-color: #ed0606;
color: #fff; }
margin: 0;
padding: 5px 5px 5px 5px;
font-size: 15px; }
#errorExplanation p {
color: #333;
margin-bottom: 0;
margin: 0;
padding: 5px; }
#errorExplanation ul li {
#errorExplanation ul, #errorExplanation li {
margin: 0; }
#errorExplanation li {
padding: 0;
font-size: 12px;
list-style: square; }

View file

@ -281,7 +281,7 @@ div.edit_form
:position fixed
:top 23%
:left 10em
:width 50em
:width 55em
:background #FBFBFB
:padding 3em
:padding-top 1em

View file

@ -33,24 +33,23 @@ h3.error
#errorExplanation
:width 40em
:border 2px solid red
:padding 7px
:padding-bottom 12px
:margin-bottom 20px
:background-color #f0f0f0
:color = !main_red
h2
:color = !main_red
:text-align left
:font-weight bold
:padding 5px 5px 5px 15px
:font-size 12px
:margin -7px
:background-color = !main_red
:color #fff
:margin 0
:padding 5px 5px 5px 5px
:font-size 15px
p
:color #333
:margin-bottom 0
:margin 0
:padding 5px
ul li
ul, li
:margin 0
li
:padding 0
:font-size 12px
:list-style square

View file

@ -0,0 +1,45 @@
require 'test_helper'
class ArticleCategoriesControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:article_categories)
end
test "should get new" do
get :new
assert_response :success
end
test "should create article_category" do
assert_difference('ArticleCategory.count') do
post :create, :article_category => { }
end
assert_redirected_to article_category_path(assigns(:article_category))
end
test "should show article_category" do
get :show, :id => article_categories(:one).id
assert_response :success
end
test "should get edit" do
get :edit, :id => article_categories(:one).id
assert_response :success
end
test "should update article_category" do
put :update, :id => article_categories(:one).id, :article_category => { }
assert_redirected_to article_category_path(assigns(:article_category))
end
test "should destroy article_category" do
assert_difference('ArticleCategory.count', -1) do
delete :destroy, :id => article_categories(:one).id
end
assert_redirected_to article_categories_path
end
end