mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-18 00:00:12 +01:00
refactor application.rb further and migrate recurring todos
next: get tests for recurring todos
This commit is contained in:
parent
484356fe07
commit
cafa774b4c
33 changed files with 688 additions and 571 deletions
|
|
@ -1,72 +1,72 @@
|
|||
class NotesController < ApplicationController
|
||||
|
||||
before_filter :set_source_view
|
||||
|
||||
def index
|
||||
@all_notes = current_user.notes.all
|
||||
@count = @all_notes.size
|
||||
@page_title = "TRACKS::All notes"
|
||||
@source_view = 'note_list'
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xml { render :xml => @all_notes.to_xml( :except => :user_id ) }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@note = current_user.notes.find(params['id'])
|
||||
@page_title = "TRACKS::Note " + @note.id.to_s
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.m { render :action => 'note_mobile' }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@note = current_user.notes.build
|
||||
@note.attributes = params["note"]
|
||||
|
||||
@saved = @note.save
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.xml do
|
||||
if @saved
|
||||
head :created, :location => note_url(@note), :text => "new note with id #{@note.id}"
|
||||
else
|
||||
render_failure @note.errors.full_messages.join(', ')
|
||||
end
|
||||
end
|
||||
format.html do
|
||||
render :text => 'unexpected request for html rendering'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@note = current_user.notes.find(params['id'])
|
||||
@note.attributes = params["note"]
|
||||
@saved = @note.save
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@note = current_user.notes.find(params['id'])
|
||||
@note.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js { @down_count = current_user.notes.size }
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_source_view
|
||||
@source_view = params['_source_view'] || 'note'
|
||||
end
|
||||
|
||||
end
|
||||
class NotesController < ApplicationController
|
||||
|
||||
before_filter :set_source_view
|
||||
|
||||
def index
|
||||
@all_notes = current_user.notes.all
|
||||
@count = @all_notes.size
|
||||
@page_title = "TRACKS::All notes"
|
||||
@source_view = 'note_list'
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xml { render :xml => @all_notes.to_xml( :except => :user_id ) }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@note = current_user.notes.find(params['id'])
|
||||
@page_title = "TRACKS::Note " + @note.id.to_s
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.m { render :action => 'note_mobile' }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@note = current_user.notes.build
|
||||
@note.attributes = params["note"]
|
||||
|
||||
@saved = @note.save
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.xml do
|
||||
if @saved
|
||||
head :created, :location => note_url(@note), :text => "new note with id #{@note.id}"
|
||||
else
|
||||
render_failure @note.errors.full_messages.join(', ')
|
||||
end
|
||||
end
|
||||
format.html do
|
||||
render :text => 'unexpected request for html rendering'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@note = current_user.notes.find(params['id'])
|
||||
@note.attributes = params["note"]
|
||||
@saved = @note.save
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@note = current_user.notes.find(params['id'])
|
||||
@note.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js { @down_count = current_user.notes.size }
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_source_view
|
||||
@source_view = params['_source_view'] || 'note'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue