Introducing Lecturers

This commit is contained in:
Thomas Blazek
2013-08-19 15:43:54 +02:00
parent 52f7e0b9ba
commit f58c359d36
25 changed files with 544 additions and 8 deletions

View 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/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the lecturers controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,83 @@
class LecturersController < ApplicationController
# GET /lecturers
# GET /lecturers.json
def index
@lecturers = Lecturer.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @lecturers }
end
end
# GET /lecturers/1
# GET /lecturers/1.json
def show
@lecturer = Lecturer.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @lecturer }
end
end
# GET /lecturers/new
# GET /lecturers/new.json
def new
@lecturer = Lecturer.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @lecturer }
end
end
# GET /lecturers/1/edit
def edit
@lecturer = Lecturer.find(params[:id])
end
# POST /lecturers
# POST /lecturers.json
def create
@lecturer = Lecturer.new(params[:lecturer])
respond_to do |format|
if @lecturer.save
format.html { redirect_to @lecturer, notice: 'Lecturer was successfully created.' }
format.json { render json: @lecturer, status: :created, location: @lecturer }
else
format.html { render action: "new" }
format.json { render json: @lecturer.errors, status: :unprocessable_entity }
end
end
end
# PUT /lecturers/1
# PUT /lecturers/1.json
def update
@lecturer = Lecturer.find(params[:id])
respond_to do |format|
if @lecturer.update_attributes(params[:lecturer])
format.html { redirect_to @lecturer, notice: 'Lecturer was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @lecturer.errors, status: :unprocessable_entity }
end
end
end
# DELETE /lecturers/1
# DELETE /lecturers/1.json
def destroy
@lecturer = Lecturer.find(params[:id])
@lecturer.destroy
respond_to do |format|
format.html { redirect_to lecturers_url }
format.json { head :no_content }
end
end
end

View File

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

4
app/models/lecturer.rb Normal file
View File

@@ -0,0 +1,4 @@
class Lecturer < ActiveRecord::Base
attr_accessible :email, :name, :oid, :picture, :lva_ids
has_and_belongs_to_many :lvas
end

View File

@@ -13,17 +13,17 @@
# updated_at :datetime not null
# modul_id :integer
# semester_id :integer
#
#
class Lva < ActiveRecord::Base
ERLAUBTE_TYPEN = ['VO', 'UE', 'VU', 'LU', 'SE', 'andere'];
has_paper_trail # Versionsverfolgung
attr_accessible :desc, :ects, :lvanr, :name, :stunden, :modul_ids, :semester_ids, :pruefungsinformation, :lernaufwand, :typ
attr_accessible :desc, :ects, :lvanr, :name, :stunden, :modul_ids, :semester_ids, :pruefungsinformation, :lernaufwand, :typ, :lecturer_ids
has_and_belongs_to_many :modul # Gehört zu einem Modul
has_and_belongs_to_many :semester
#Gehört zu einem Semester( derzeit nicht implementiert)
has_many :beispiele , :class_name => "Beispiel"
has_and_belongs_to_many :lecturers
translates :desc, :fallbacks_for_empty_translations => true
validates :lvanr,:format=>{ :with => /^[0-9][0-9][0-9]\.[0-9][0-9][0-9]$/}, :presence=>true, :uniqueness=>true # , :uniqueness=>true # LVA-Nummer muss das Format 000.000 besitzen (uniqueness?) oder 000 für nicht

View File

@@ -0,0 +1,13 @@
<%= semantic_form_for @lecturer do |f| %>
<%= f.inputs do %>
<%= f.input :name %>
<%= f.input :email %>
<%= f.input :oid %>
<%= f.input :picture %>
<%= f.input :lvas %>
<% end %>
<%= f.actions do %>
<%= f.action :submit, :as => :input %>
<% end %>
<% end %>

View File

@@ -0,0 +1,6 @@
<h1>Editing lecturer</h1>
<%= render 'form' %>
<%= link_to 'Show', @lecturer %> |
<%= link_to 'Back', lecturers_path %>

View File

@@ -0,0 +1,29 @@
<h1>Listing lecturers</h1>
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Oid</th>
<th>Picture</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @lecturers.each do |lecturer| %>
<tr>
<td><%= lecturer.name %></td>
<td><%= lecturer.email %></td>
<td><%= lecturer.oid %></td>
<td><%= lecturer.picture %></td>
<td><%= link_to 'Show', lecturer %></td>
<td><%= link_to 'Edit', edit_lecturer_path(lecturer) %></td>
<td><%= link_to 'Destroy', lecturer, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Lecturer', new_lecturer_path %>

View File

@@ -0,0 +1,5 @@
<h1>New lecturer</h1>
<%= render 'form' %>
<%= link_to 'Back', lecturers_path %>

View File

@@ -0,0 +1,25 @@
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @lecturer.name %>
</p>
<p>
<b>Email:</b>
<%= @lecturer.email %>
</p>
<p>
<b>Oid:</b>
<%= @lecturer.oid %>
</p>
<p>
<b>Picture:</b>
<%= @lecturer.picture %>
</p>
<%= link_to 'Edit', edit_lecturer_path(@lecturer) %> |
<%= link_to 'Back', lecturers_path %>

View File

@@ -1,9 +1,9 @@
<div class="lva-semester">
<b><%= link_to lva.name, lva_path(lva)%></b><br>
<%=lva.lvanr.to_s %> <b><%= link_to lva.name, lva_path(lva)%></b> <%= lva.ects %> ECTS / <%= lva.stunden %> Std<br>
<!-- <div class="hidden-phone">
Module: /<% lva.modul.each do |m| %> <%= link_to m.name + ' / ', modul_path(m) unless m.modulgruppen.map{|x| x.studium}.index(@studium).nil? && !@studium.nil? %><% end %>
<br>
<%="LVa-Nr " + lva.lvanr.to_s %>
<%= lva.ects %> ECTS / <%= lva.stunden %> Std <% " / " + lva.beispiele.count.to_s + " Beispiele"%> <br>
<%= link_to "Edit", edit_lva_path(lva) %> | <%= link_to "Beispiel hinzufügen", new_beispiel_path(:lva_id=>lva.id) %>
<br>
<% " / " + lva.beispiele.count.to_s + " Beispiele"%> </div>-->
</div class="lva-semester">