forked from bofh/fetsite
Beispiele hinzugefügt
This commit is contained in:
20
Gemfile.lock
20
Gemfile.lock
@@ -35,6 +35,7 @@ GEM
|
|||||||
sass (~> 3.2)
|
sass (~> 3.2)
|
||||||
builder (3.0.4)
|
builder (3.0.4)
|
||||||
cancan (1.6.9)
|
cancan (1.6.9)
|
||||||
|
cocaine (0.4.2)
|
||||||
coffee-rails (3.2.2)
|
coffee-rails (3.2.2)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
railties (~> 3.2.0)
|
railties (~> 3.2.0)
|
||||||
@@ -77,6 +78,12 @@ GEM
|
|||||||
paper_trail (2.7.0)
|
paper_trail (2.7.0)
|
||||||
activerecord (~> 3.0)
|
activerecord (~> 3.0)
|
||||||
railties (~> 3.0)
|
railties (~> 3.0)
|
||||||
|
paperclip (3.4.0)
|
||||||
|
activemodel (>= 3.0.0)
|
||||||
|
activerecord (>= 3.0.0)
|
||||||
|
activesupport (>= 3.0.0)
|
||||||
|
cocaine (~> 0.4.0)
|
||||||
|
mime-types
|
||||||
polyglot (0.3.3)
|
polyglot (0.3.3)
|
||||||
rack (1.4.5)
|
rack (1.4.5)
|
||||||
rack-cache (1.2)
|
rack-cache (1.2)
|
||||||
@@ -142,17 +149,18 @@ DEPENDENCIES
|
|||||||
bootstrap-sass (~> 2.2.0)
|
bootstrap-sass (~> 2.2.0)
|
||||||
cancan
|
cancan
|
||||||
coffee-rails (~> 3.2.1)
|
coffee-rails (~> 3.2.1)
|
||||||
devise
|
devise (~> 2.2.3)
|
||||||
execjs
|
execjs (~> 1.4.0)
|
||||||
formtastic
|
formtastic (~> 2.2.1)
|
||||||
formtastic-bootstrap
|
formtastic-bootstrap
|
||||||
globalize3
|
globalize3 (~> 0.3.0)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
paper_trail
|
paper_trail (>= 2.7.0)
|
||||||
|
paperclip (~> 3.4.0)
|
||||||
rails (= 3.2.9)
|
rails (= 3.2.9)
|
||||||
rolify
|
rolify
|
||||||
sass-rails (~> 3.2.3)
|
sass-rails (~> 3.2.3)
|
||||||
sqlite3
|
sqlite3
|
||||||
therubyracer
|
therubyracer
|
||||||
tinymce-rails
|
tinymce-rails (>= 3.5.8)
|
||||||
uglifier (>= 1.0.3)
|
uglifier (>= 1.0.3)
|
||||||
|
|||||||
3
app/assets/javascripts/beispiele.js.coffee
Normal file
3
app/assets/javascripts/beispiele.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://jashkenas.github.com/coffee-script/
|
||||||
3
app/assets/stylesheets/beispiele.css.scss
Normal file
3
app/assets/stylesheets/beispiele.css.scss
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
// Place all the styles related to the beispiele controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||||
83
app/controllers/beispiele_controller.rb
Normal file
83
app/controllers/beispiele_controller.rb
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
class BeispieleController < ApplicationController
|
||||||
|
# GET /beispiele
|
||||||
|
# GET /beispiele.json
|
||||||
|
def index
|
||||||
|
@beispiele = Beispiel.all
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.json { render json: @beispiele }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /beispiele/1
|
||||||
|
# GET /beispiele/1.json
|
||||||
|
def show
|
||||||
|
@beispiel = Beispiel.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # show.html.erb
|
||||||
|
format.json { render json: @beispiel }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /beispiele/new
|
||||||
|
# GET /beispiele/new.json
|
||||||
|
def new
|
||||||
|
@beispiel = Beispiel.new
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # new.html.erb
|
||||||
|
format.json { render json: @beispiel }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /beispiele/1/edit
|
||||||
|
def edit
|
||||||
|
@beispiel = Beispiel.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /beispiele
|
||||||
|
# POST /beispiele.json
|
||||||
|
def create
|
||||||
|
@beispiel = Beispiel.new(params[:beispiel])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @beispiel.save
|
||||||
|
format.html { redirect_to @beispiel, notice: 'Beispiel was successfully created.' }
|
||||||
|
format.json { render json: @beispiel, status: :created, location: @beispiel }
|
||||||
|
else
|
||||||
|
format.html { render action: "new" }
|
||||||
|
format.json { render json: @beispiel.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PUT /beispiele/1
|
||||||
|
# PUT /beispiele/1.json
|
||||||
|
def update
|
||||||
|
@beispiel = Beispiel.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @beispiel.update_attributes(params[:beispiel])
|
||||||
|
format.html { redirect_to @beispiel, notice: 'Beispiel was successfully updated.' }
|
||||||
|
format.json { head :no_content }
|
||||||
|
else
|
||||||
|
format.html { render action: "edit" }
|
||||||
|
format.json { render json: @beispiel.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /beispiele/1
|
||||||
|
# DELETE /beispiele/1.json
|
||||||
|
def destroy
|
||||||
|
@beispiel = Beispiel.find(params[:id])
|
||||||
|
@beispiel.destroy
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to beispiele_url }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
2
app/helpers/beispiele_helper.rb
Normal file
2
app/helpers/beispiele_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
module BeispieleHelper
|
||||||
|
end
|
||||||
7
app/models/beispiel.rb
Normal file
7
app/models/beispiel.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
class Beispiel < ActiveRecord::Base
|
||||||
|
has_paper_trail
|
||||||
|
attr_accessible :desc, :name, :file, :lva_id
|
||||||
|
has_attached_file :file
|
||||||
|
belongs_to :lva
|
||||||
|
translates :desc, :fallbacks_for_empty_translations => true
|
||||||
|
end
|
||||||
@@ -4,4 +4,5 @@ class Lva < ActiveRecord::Base
|
|||||||
has_and_belongs_to_many :modul
|
has_and_belongs_to_many :modul
|
||||||
has_and_belongs_to_many :semester
|
has_and_belongs_to_many :semester
|
||||||
translates :desc, :fallbacks_for_empty_translations => true
|
translates :desc, :fallbacks_for_empty_translations => true
|
||||||
|
has_many :beispiele , :class_name => "Beispiel"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,7 +9,5 @@ def moderator
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def moderator=(id)
|
|
||||||
User.find(id).add_role(:newsmoderator, self)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
12
app/views/beispiele/_form.html.erb
Normal file
12
app/views/beispiele/_form.html.erb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<%= semantic_form_for @beispiel, :html => { :multipart => true } do |f| %>
|
||||||
|
<%= f.inputs do %>
|
||||||
|
<%= f.input :name %>
|
||||||
|
<%= f.input :desc %>
|
||||||
|
<%= f.input :file , :as=>:file %>
|
||||||
|
<%= f.input :lva, :as=>:radio, :collection => Lva.all%>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= f.actions do %>
|
||||||
|
<%= f.action :submit, :as => :input %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
6
app/views/beispiele/edit.html.erb
Normal file
6
app/views/beispiele/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<h1>Editing beispiel</h1>
|
||||||
|
|
||||||
|
<%= render 'form' %>
|
||||||
|
|
||||||
|
<%= link_to 'Show', @beispiel %> |
|
||||||
|
<%= link_to 'Back', beispiele_path %>
|
||||||
25
app/views/beispiele/index.html.erb
Normal file
25
app/views/beispiele/index.html.erb
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<h1>Listing beispiele</h1>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Desc</th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% @beispiele.each do |beispiel| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= beispiel.name %></td>
|
||||||
|
<td><%= beispiel.desc %></td>
|
||||||
|
<td><%= link_to 'Show', beispiel %></td>
|
||||||
|
<td><%= link_to 'Edit', edit_beispiel_path(beispiel) %></td>
|
||||||
|
<td><%= link_to 'Destroy', beispiel, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<%= link_to 'New Beispiel', new_beispiel_path %>
|
||||||
5
app/views/beispiele/new.html.erb
Normal file
5
app/views/beispiele/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<h1>New beispiel</h1>
|
||||||
|
|
||||||
|
<%= render 'form' %>
|
||||||
|
|
||||||
|
<%= link_to 'Back', beispiele_path %>
|
||||||
16
app/views/beispiele/show.html.erb
Normal file
16
app/views/beispiele/show.html.erb
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<p id="notice"><%= notice %></p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<b>Name:</b>
|
||||||
|
<%= @beispiel.name %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<b>Desc:</b>
|
||||||
|
<%= @beispiel.desc %>
|
||||||
|
<%= @beispiel.file.url %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<%= link_to 'Edit', edit_beispiel_path(@beispiel) %> |
|
||||||
|
<%= link_to 'Back', beispiele_path %>
|
||||||
@@ -16,5 +16,7 @@
|
|||||||
<p>
|
<p>
|
||||||
<%= @lva.desc %>
|
<%= @lva.desc %>
|
||||||
</p>
|
</p>
|
||||||
|
<% @lva.beispiele.each do |beispiel| %>
|
||||||
|
<%= link_to beispiel.name, beispiel.file.url %>
|
||||||
|
|
||||||
|
<% end%>
|
||||||
|
|||||||
@@ -23,4 +23,6 @@ inflect.singular 'modulgruppen', 'modulgruppe'
|
|||||||
inflect.irregular 'modulgruppe', 'modulgruppen'
|
inflect.irregular 'modulgruppe', 'modulgruppen'
|
||||||
inflect.plural 'rubrik', 'rubriken'
|
inflect.plural 'rubrik', 'rubriken'
|
||||||
inflect.singular 'rubriken', 'rubrik'
|
inflect.singular 'rubriken', 'rubrik'
|
||||||
|
inflect.plural 'beispiel', 'beispiele'
|
||||||
|
inflect.singular 'beispiele', 'beispiel'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ Fetsite::Application.routes.draw do
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
resources :beispiele
|
||||||
|
|
||||||
|
|
||||||
devise_for :users
|
devise_for :users
|
||||||
scope '(:locale)/admin' do
|
scope '(:locale)/admin' do
|
||||||
resources :users
|
resources :users
|
||||||
|
|||||||
21
db/migrate/20130214233723_create_beispiele.rb
Normal file
21
db/migrate/20130214233723_create_beispiele.rb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
class CreateBeispiele < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
create_table :beispiele do |t|
|
||||||
|
t.string :name
|
||||||
|
t.text :desc
|
||||||
|
t.integer :lva_id
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
add_attachment :beispiele, :file
|
||||||
|
Beispiel.create_translation_table!({
|
||||||
|
:desc => :text,
|
||||||
|
})
|
||||||
|
add_column :beispiel_translations, :beispiele_id, :integer
|
||||||
|
remove_column :beispiel_translations, :beispiel_id
|
||||||
|
end
|
||||||
|
def down
|
||||||
|
Beispiel.drop_translation_table! #:migrate_data => true
|
||||||
|
drop_table :beispiele
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
38
db/schema.rb
38
db/schema.rb
@@ -11,7 +11,29 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20130124223508) do
|
ActiveRecord::Schema.define(:version => 20130214233723) do
|
||||||
|
|
||||||
|
create_table "beispiel_translations", :force => true do |t|
|
||||||
|
t.string "locale"
|
||||||
|
t.text "desc"
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
t.integer "beispiele_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "beispiel_translations", ["locale"], :name => "index_beispiel_translations_on_locale"
|
||||||
|
|
||||||
|
create_table "beispiele", :force => true do |t|
|
||||||
|
t.string "name"
|
||||||
|
t.text "desc"
|
||||||
|
t.integer "lva_id"
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
t.string "file_file_name"
|
||||||
|
t.string "file_content_type"
|
||||||
|
t.integer "file_file_size"
|
||||||
|
t.datetime "file_updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "lva_translations", :force => true do |t|
|
create_table "lva_translations", :force => true do |t|
|
||||||
t.integer "lva_id"
|
t.integer "lva_id"
|
||||||
@@ -30,10 +52,9 @@ ActiveRecord::Schema.define(:version => 20130124223508) do
|
|||||||
t.decimal "ects"
|
t.decimal "ects"
|
||||||
t.string "lvanr"
|
t.string "lvanr"
|
||||||
t.decimal "stunden"
|
t.decimal "stunden"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "modul_id"
|
t.integer "modul_id"
|
||||||
t.integer "semester_id"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "lvas_moduls", :id => false, :force => true do |t|
|
create_table "lvas_moduls", :id => false, :force => true do |t|
|
||||||
@@ -84,9 +105,10 @@ ActiveRecord::Schema.define(:version => 20130124223508) do
|
|||||||
create_table "moduls", :force => true do |t|
|
create_table "moduls", :force => true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.text "desc"
|
t.text "desc"
|
||||||
t.text "depend"
|
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
|
t.text "depend"
|
||||||
|
t.integer "studium_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "neuigkeiten", :force => true do |t|
|
create_table "neuigkeiten", :force => true do |t|
|
||||||
@@ -120,8 +142,8 @@ ActiveRecord::Schema.define(:version => 20130124223508) do
|
|||||||
create_table "semesters", :force => true do |t|
|
create_table "semesters", :force => true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.integer "nummer"
|
t.integer "nummer"
|
||||||
t.integer "studium_id"
|
t.boolean "ws"
|
||||||
t.string "ssws"
|
t.boolean "ss"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
@@ -129,7 +151,6 @@ ActiveRecord::Schema.define(:version => 20130124223508) do
|
|||||||
create_table "studien", :force => true do |t|
|
create_table "studien", :force => true do |t|
|
||||||
t.string "zahl"
|
t.string "zahl"
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.text "shortdesc"
|
|
||||||
t.text "desc"
|
t.text "desc"
|
||||||
t.string "typ"
|
t.string "typ"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
@@ -139,7 +160,6 @@ ActiveRecord::Schema.define(:version => 20130124223508) do
|
|||||||
create_table "studium_translations", :force => true do |t|
|
create_table "studium_translations", :force => true do |t|
|
||||||
t.string "locale"
|
t.string "locale"
|
||||||
t.text "desc"
|
t.text "desc"
|
||||||
t.text "shortdesc"
|
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "studien_id"
|
t.integer "studien_id"
|
||||||
|
|||||||
BIN
public/system/beispiele/files/000/000/001/original/uninst.exe
Normal file
BIN
public/system/beispiele/files/000/000/001/original/uninst.exe
Normal file
Binary file not shown.
9
test/fixtures/beispiele.yml
vendored
Normal file
9
test/fixtures/beispiele.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
name:
|
||||||
|
desc: MyText
|
||||||
|
|
||||||
|
two:
|
||||||
|
name:
|
||||||
|
desc: MyText
|
||||||
49
test/functional/beispiele_controller_test.rb
Normal file
49
test/functional/beispiele_controller_test.rb
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class BeispieleControllerTest < ActionController::TestCase
|
||||||
|
setup do
|
||||||
|
@beispiel = beispiele(:one)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should get index" do
|
||||||
|
get :index
|
||||||
|
assert_response :success
|
||||||
|
assert_not_nil assigns(:beispiele)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should get new" do
|
||||||
|
get :new
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should create beispiel" do
|
||||||
|
assert_difference('Beispiel.count') do
|
||||||
|
post :create, beispiel: { desc: @beispiel.desc, name: @beispiel.name }
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_redirected_to beispiel_path(assigns(:beispiel))
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should show beispiel" do
|
||||||
|
get :show, id: @beispiel
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should get edit" do
|
||||||
|
get :edit, id: @beispiel
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should update beispiel" do
|
||||||
|
put :update, id: @beispiel, beispiel: { desc: @beispiel.desc, name: @beispiel.name }
|
||||||
|
assert_redirected_to beispiel_path(assigns(:beispiel))
|
||||||
|
end
|
||||||
|
|
||||||
|
test "should destroy beispiel" do
|
||||||
|
assert_difference('Beispiel.count', -1) do
|
||||||
|
delete :destroy, id: @beispiel
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_redirected_to beispiele_path
|
||||||
|
end
|
||||||
|
end
|
||||||
7
test/unit/beispiel_test.rb
Normal file
7
test/unit/beispiel_test.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class BeispielTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
4
test/unit/helpers/beispiele_helper_test.rb
Normal file
4
test/unit/helpers/beispiele_helper_test.rb
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class BeispieleHelperTest < ActionView::TestCase
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user