Refactor courses

This commit is contained in:
2015-09-04 13:45:37 -04:00
parent 022620e4ab
commit 6f1427dc21
25 changed files with 339 additions and 361 deletions

View File

@@ -20,21 +20,28 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
class AttachmentLogEntry < LogEntry
belongs_to :attachment,
:foreign_key => "target_id",
:with_deleted => true
belongs_to :attachment,
:foreign_key => "target_id",
:with_deleted => true
end
class AttachmentDeleteLogEntry < AttachmentLogEntry
def reversible?()
attachment.deleted?
end
def undo!(current_user)
attachment.update_attribute(:deleted_at, nil)
AttachmentRestoreLogEntry.create!(:target_id => attachment.id, :user_id => current_user.id, :course => attachment.course)
end
def reversible?()
attachment.deleted?
end
def undo!(current_user)
attachment.update_attribute(:deleted_at, nil)
AttachmentRestoreLogEntry.create!(:target_id => attachment.id,
:user_id => current_user.id, :course => attachment.course)
end
end
class AttachmentEditLogEntry < AttachmentLogEntry; end
class AttachmentCreateLogEntry < AttachmentLogEntry; end
class AttachmentRestoreLogEntry < AttachmentLogEntry; end
class AttachmentEditLogEntry < AttachmentLogEntry
end
class AttachmentCreateLogEntry < AttachmentLogEntry
end
class AttachmentRestoreLogEntry < AttachmentLogEntry
end

View File

@@ -20,21 +20,27 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
class EventLogEntry < LogEntry
belongs_to :event,
:foreign_key => "target_id",
:with_deleted => true
belongs_to :event,
:foreign_key => "target_id",
:with_deleted => true
end
class EventDeleteLogEntry < EventLogEntry
def reversible?()
event.deleted?
end
def undo!(current_user)
event.recover!
EventRestoreLogEntry.create!(:target_id => event.id, :user_id => current_user.id, :course => event.course, :version => event.version)
end
def reversible?()
event.deleted?
end
def undo!(current_user)
event.recover!
EventRestoreLogEntry.create!(:target_id => event.id, :user_id => current_user.id, :course => event.course, :version => event.version)
end
end
class EventEditLogEntry < EventLogEntry; end
class EventCreateLogEntry < EventLogEntry; end
class EventRestoreLogEntry < EventLogEntry; end
class EventEditLogEntry < EventLogEntry
end
class EventCreateLogEntry < EventLogEntry
end
class EventRestoreLogEntry < EventLogEntry
end