forked from bofh/fetsite
AutoCommit Mit Jun 10 17:03:04 CEST 2015
This commit is contained in:
@@ -3,8 +3,8 @@ class CalendarsController < ApplicationController
|
||||
# GET /calendars.json
|
||||
load_and_authorize_resource
|
||||
def index
|
||||
@calendars = Calendar.accessible_by(current_ability)
|
||||
@calentries = Calentry.accessible_by(current_ability)
|
||||
@calendars = Calendar.accessible_by(current_ability,:show)
|
||||
@calentries =@calendars.map{|c| c.calentries }.flatten
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
||||
1
app/models/.#key.rb
Symbolic link
1
app/models/.#key.rb
Symbolic link
@@ -0,0 +1 @@
|
||||
andreas@andreas-ThinkPad-S430.6916:1433938439
|
||||
@@ -160,16 +160,19 @@ end
|
||||
cannot :delete, Meeting
|
||||
end
|
||||
if user.has_role?( "fetadmin")
|
||||
can :manage, Meetingtyp
|
||||
|
||||
end
|
||||
|
||||
can :manage, Meetingtyp
|
||||
|
||||
end
|
||||
|
||||
# Rechteverwaltung Kalender
|
||||
can [:show, :index], Calendar, :public => true
|
||||
can [:showics], Calendar
|
||||
can [:show], Calentry
|
||||
# can [:show], Calentry
|
||||
if (!k.nil? && k.typ==1 && (k.user.has_role?("fetuser")||k.user.has_role?("fetadmin")))
|
||||
can [:show,:index], Calendar
|
||||
end
|
||||
|
||||
if( user.has_role?("fetuser") || user.has_role?("fetadmin")|| (!k.nil? && k.typ==1 && (k.user.has_role?("fetuser")||k.user.has_role?("fetadmin"))))
|
||||
if( user.has_role?("fetuser") || user.has_role?("fetadmin")||)
|
||||
can [:show,:index], Calendar
|
||||
can [:edit, :update,:new,:create,:verwalten], Calendar
|
||||
can [:edit, :update,:new,:create,:verwalten,:delete], Calentry
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Key < ActiveRecord::Base
|
||||
attr_accessible :expire, :is_valid, :type, :user_id
|
||||
attr_accessible :expire, :is_valid, :typ,
|
||||
belongs_to :parent, :polymorphic => true
|
||||
belongs_to :user
|
||||
before_create :create_unique_identifier
|
||||
@@ -8,4 +8,27 @@ class Key < ActiveRecord::Base
|
||||
self.uuid = SecureRandom.hex(10) # or whatever you chose like UUID tools
|
||||
end while self.class.exists?(:uuid => uuid)
|
||||
end
|
||||
def self.find_or_create(user, typ, parent=nil)
|
||||
if parent.nil? || !parent
|
||||
kk=Key.where(user_id: user.id, typ: typ, is_valid: true).first
|
||||
if kk.nil?
|
||||
kk=Key.new
|
||||
kk.user=user
|
||||
kk.typ = typ
|
||||
kk.is_valid = true
|
||||
end
|
||||
else
|
||||
kk=Key.where(user_id: user.id, typ: typ, is_valid: true, parent_type: parent.class.to_s, parent_id: parent.id).first
|
||||
|
||||
if kk.nil?
|
||||
kk=Key.new
|
||||
kk.user=user
|
||||
kk.typ = typ
|
||||
kk.is_valid = true
|
||||
kk.parent=parent
|
||||
|
||||
end
|
||||
end
|
||||
kk
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,4 +33,14 @@
|
||||
<%= link_to 'New Calendar', new_calendar_path unless cannot?(:new, Calendar) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul>
|
||||
<% @calentries.each do |entry| %>
|
||||
<li>
|
||||
<%= link_to entry.summary.to_s + " - " + I18n.l(entry.start1), entry %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user