Add schulden csv voor iepoev
This commit is contained in:
parent
bbc8901353
commit
cb94f2dbb8
9 changed files with 38 additions and 0 deletions
3
app/assets/javascripts/admins.js.coffee
Normal file
3
app/assets/javascripts/admins.js.coffee
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
3
app/assets/stylesheets/admins.css.scss
Normal file
3
app/assets/stylesheets/admins.css.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the admins controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
12
app/controllers/admins_controller.rb
Normal file
12
app/controllers/admins_controller.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require 'csv'
|
||||
class AdminsController < ApplicationController
|
||||
def schulden
|
||||
@users = User.all
|
||||
respond_to do |format|
|
||||
format.csv do
|
||||
headers['Content-Disposition'] = "attachment; filename=\"zeus-schulden\""
|
||||
headers['Content-Type'] ||= 'text/csv'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
2
app/helpers/admins_helper.rb
Normal file
2
app/helpers/admins_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
module AdminsHelper
|
||||
end
|
5
app/views/admins/schulden.csv.erb
Normal file
5
app/views/admins/schulden.csv.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
<%- headers = ['nickname', 'schulden'] -%>
|
||||
<%= CSV.generate_line headers %>
|
||||
<%- @users.each do |user| -%>
|
||||
<%= CSV.generate_line([user.nickname, user.balance]) %>
|
||||
<%- end -%>
|
|
@ -40,6 +40,7 @@
|
|||
<li><%= link_to "List" , users_path %></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><%= link_to 'Download schulden', admins_schulden_path(format: :csv) %>/li>
|
||||
<% end %>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Logged in as <%= current_user.nickname %> <b class="caret"></b></a>
|
||||
|
|
|
@ -12,4 +12,5 @@ Rails.application.routes.draw do
|
|||
end
|
||||
|
||||
resources :products
|
||||
get 'admins' => 'admins#schulden', as: "admins_schulden"
|
||||
end
|
||||
|
|
7
test/controllers/admins_controller_test.rb
Normal file
7
test/controllers/admins_controller_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminsControllerTest < ActionController::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
4
test/helpers/admins_helper_test.rb
Normal file
4
test/helpers/admins_helper_test.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminsHelperTest < ActionView::TestCase
|
||||
end
|
Loading…
Reference in a new issue