small improvements

render :partial => filename, :object => @object can be written shorter since rails 2.0 like
render :partial => @object or render :partial => @collection
Also form_for is smart bout put and post for update and creation.

it helps watching older railcasts episodes :-)
This commit is contained in:
Reinier Balt 2010-11-29 11:04:15 +01:00
parent edb3668dba
commit 484356fe07
15 changed files with 51 additions and 52 deletions

View file

@ -18,13 +18,7 @@ class NotesController < ApplicationController
@page_title = "TRACKS::Note " + @note.id.to_s
respond_to do |format|
format.html
format.m &render_note_mobile
end
end
def render_note_mobile
lambda do
render :action => 'note_mobile'
format.m { render :action => 'note_mobile' }
end
end
@ -49,16 +43,6 @@ class NotesController < ApplicationController
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
def update
@note = current_user.notes.find(params['id'])
@note.attributes = params["note"]
@ -69,11 +53,20 @@ class NotesController < ApplicationController
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

View file

@ -56,7 +56,7 @@ class ProjectsController < ApplicationController
@next_project = current_user.projects.next_from(@project)
@previous_project = current_user.projects.previous_from(@project)
@default_tags = @project.default_tags
@new_note = current_user.notes.build
@new_note = current_user.notes.new
@new_note.project_id = @project.id
respond_to do |format|
format.html

View file

@ -104,11 +104,11 @@ module ApplicationHelper
end
def link_to_context(context, descriptor = sanitize(context.name))
link_to( descriptor, context_path(context), :title => "View context: #{context.name}" )
link_to( descriptor, context, :title => "View context: #{context.name}" )
end
def link_to_project(project, descriptor = sanitize(project.name))
link_to( descriptor, project_path(project), :title => "View project: #{project.name}" )
link_to( descriptor, project, :title => "View project: #{project.name}" )
end
def link_to_edit_project (project, descriptor = sanitize(project.name))

View file

@ -53,7 +53,7 @@
</li>
<li>Open Script Editor and paste the script into a new document.</li>
<li>Compile and save the script to the ~/Library/Scriipts/Mail Scripts directory.</li>
<li>For more information on using AppleScript with Mail.app, see <a href="http://www.apple.com/applescript/mail/" title="Scriptable Applications: Mail">this overview</a>.
<li>For more information on using AppleScript with Mail.app, see <a href="http://www.apple.com/applescript/mail/" title="Scriptable Applications: Mail">this overview</a>.</li>
</ol>
<% else %>
<br/><p><i>You do not have any context yet. The script will be available after you add your first context</i></p>
@ -98,6 +98,7 @@
<h2>Integrated email/SMS receiver</h2>
<p>
If Tracks is running on the same server as your mail server, you can use the integrated mail handler built into tracks. Steps to set it up:
</p>
<ul>
<li>Go to <%= link_to "Preferences", preferences_url %> and set your "From email" and "default email context" for todos sent in via email (which could come from an SMS message)</li>
<li>In sendmail/qmail/postfix/whatever, set up an email address alias to pipe messages to <pre >/PATH/TO/RUBY/ruby /PATH/TO/TRACKS/script/runner -e production 'MessageGateway.receive(STDIN.read)'</pre></li>
@ -122,9 +123,3 @@
<li>Paste following link to the Add a gadget by its URL: and then click Add button:<br/>
<pre><%= integrations_url + "/google_gadget" %></pre></li>
</ul>
<Module>
<ModulePrefs title="GTDify" directory_title="GTDify" description="Official gadget for GTDify service." author="GTDify" author_email="support@gtdify.com" author_affiliation="GTDify" author_location="NJ, USA" title_url="http://www.gtdify.com/" screenshot="http://www.gtdify.com/modules/gmail/ss.png" thumbnail="http://www.gtdify.com/modules/gmail/tn.png" category="communication" category2="tools" height="300">
</ModulePrefs>
<Content type="url" href="http://my.gtdify.com/mobile/"/>
</Module>

View file

@ -53,7 +53,7 @@
</li>
<li>Open Script Editor and paste the script into a new document.</li>
<li>Compile and save the script to the ~/Library/Scriipts/Mail Scripts directory.</li>
<li>For more information on using AppleScript with Mail.app, see <a href="http://www.apple.com/applescript/mail/" title="Scriptable Applications: Mail">this overview</a>.
<li>For more information on using AppleScript with Mail.app, see <a href="http://www.apple.com/applescript/mail/" title="Scriptable Applications: Mail">this overview</a>.</li>
</ol>
<% else %>
<br/><p><i>You do not have any context yet. The script will be available after you add your first context</i></p>
@ -98,6 +98,7 @@
<h2>Integrated email/SMS receiver</h2>
<p>
If Tracks is running on the same server as your mail server, you can use the integrated mail handler built into tracks. Steps to set it up:
</p>
<ul>
<li>Go to <%= link_to "Preferences", preferences_url %> and set your "From email" and "default email context" for todos sent in via email (which could come from an SMS message)</li>
<li>In sendmail/qmail/postfix/whatever, set up an email address alias to pipe messages to <pre >/PATH/TO/RUBY/ruby /PATH/TO/TRACKS/script/runner -e production 'MessageGateway.receive(STDIN.read)'</pre></li>
@ -122,9 +123,3 @@
<li>Paste following link to the Add a gadget by its URL: and then click Add button:<br/>
<pre><%= integrations_url + "/google_gadget" %></pre></li>
</ul>
<Module>
<ModulePrefs title="GTDify" directory_title="GTDify" description="Official gadget for GTDify service." author="GTDify" author_email="support@gtdify.com" author_affiliation="GTDify" author_location="NJ, USA" title_url="http://www.gtdify.com/" screenshot="http://www.gtdify.com/modules/gmail/ss.png" thumbnail="http://www.gtdify.com/modules/gmail/tn.png" category="communication" category2="tools" height="300">
</ModulePrefs>
<Content type="url" href="http://my.gtdify.com/mobile/"/>
</Module>

View file

@ -1,7 +1,7 @@
<div class="container" id="note-<%= note.id %>-wrapper">
<div id="<%= dom_id(note, 'container') %>">
<h2><%= link_to(t('notes.note_header', :id => note.id.to_s), note_path(note), :title => t('notes.note_link_title', :id => note.id.to_s)) %></h2>
<h2><%= link_to(t('notes.note_header', :id => note.id.to_s), note, :title => t('notes.note_link_title', :id => note.id.to_s)) %></h2>
<div class="project_notes" id="<%= dom_id(note) %>">
<%= render :partial => "notes/note_details", :object => note %>

View file

@ -6,7 +6,7 @@
<%= link_to_delete_note(note, image_tag( "blank.png",:title => t('notes.delete_item_title'), :class=>"delete_item")) %> &nbsp;
<%= link_to_edit_note(note, image_tag( "blank.png", :title => t('notes.edit_item_title'), :class=>"edit_item") ) %>
| <%= link_to("In: " + note.project.name, project_path(note.project), :class=>"footer_link" ) %>&nbsp;|&nbsp;
| <%= link_to("In: " + note.project.name, note.project, :class=>"footer_link" ) %>&nbsp;|&nbsp;
<%= Note.human_attribute_name('created_at') %>: <%= format_date(note.created_at) %>

View file

@ -1,12 +1,9 @@
<%
submit_text ||= t('common.update')
# :put for edit note and :post for new note
form_method ||= :put
form_for(note_edit_form, :html => {
:id => dom_id(note_edit_form, 'edit_form'),
:class => "inline-form edit-note-form",
:method => form_method }) do |f|
:class => "inline-form edit-note-form"}) do |f|
-%>
<div id="error_status"><%= error_messages_for("note") %></div>

View file

@ -2,7 +2,7 @@
<div class="note_wrapper" id="<%= dom_id(note) %>">
<%= link_to(
image_tag("blank.png", :border => 0),
note_path(note),
note,
:title => t('notes.show_note_title'),
:class => "link_to_notes icon",
:id => dom_id(note, "link")) %>&nbsp;

View file

@ -2,6 +2,6 @@
<% if @all_notes.empty? -%>
<div class="message"><p><%= t('notes.no_notes_available') %></p></div>
<% else -%>
<%= render :partial => 'note', :collection => @all_notes %>
<%= render :partial => @all_notes %>
<% end -%>
</div>

View file

@ -1,3 +1,3 @@
<div id="display_box_projects">
<%= render :partial => 'note', :object => @note %>
<%= render :partial => @note %>
</div>

View file

@ -3,7 +3,7 @@
<%= project_next_prev %>
</div>
<%= render :partial => "projects/project", :locals => { :project => @project, :collapsible => false } %>
<%= render :partial => @project, :locals => {:collapsible => false } %>
<%= render :partial => "todos/deferred", :locals => { :deferred => @deferred, :collapsible => false, :append_descriptor => t('projects.todos_append'), :parent_container_type => 'project', :pending => @pending } %>
<% unless @max_completed==0 -%>
<%= render :partial => "todos/completed", :locals => { :done => @done, :collapsible => false, :suppress_project => true, :append_descriptor => t('projects.todos_append') } %>
@ -22,7 +22,7 @@
</div>
<div id="new-note" style="display:none;">
<%= render :partial => "notes/note_edit_form", :object => @new_note, :locals => {:submit_text => t('projects.add_note_submit'), :form_method => :post} %>
<%= render :partial => "notes/note_edit_form", :object => @new_note, :locals => {:submit_text => t('projects.add_note_submit')} %>
</div>
</div>

View file

@ -5,7 +5,7 @@
<div id="recurring-todos-empty-nd" style="<%= @no_recurring_todos ? 'display:block' : 'display:none'%>">
<div class="message"><p><%= t('todos.no_recurring_todos') %></p></div>
</div>
<%= render :partial => "recurring_todo", :collection => @recurring_todos %>
<%= render :partial => @recurring_todos %>
</div>
</div>
@ -15,7 +15,7 @@
<div id="completed-empty-nd" style="<%= @no_completed_recurring_todos ? 'display:block' : 'display:none'%>">
<div class="message"><p><%= t('todos.no_completed_recurring') %></p></div>
</div>
<%= render :partial => "recurring_todo", :collection => @completed_recurring_todos %>
<%= render :partial => @completed_recurring_todos %>
</div>
</div>
</div>

View file

@ -1,4 +1,4 @@
<h2><%= t('todos.next_action_description') + link_to(t('common.go_back'), @return_path) %>)</h2>
<h2><%= t('todos.next_action_description') + " (" + link_to(t('common.go_back'), @return_path) %>)</h2>
<%= link_to @todo.description, todo_path(@todo, :format => 'm') -%>
<h2><%= t('todos.notes') %></h2>
<%= format_note(@todo.notes) %>

View file

@ -0,0 +1,19 @@
Feature: Manage preferences
In order to customize Tracks to my needs
As a Tracks user
I want to be be able change my preferences
Background:
Given the following user record
| login | password | is_admin |
| testuser | secret | false |
And I have logged in as "testuser" with password "secret"
Scenario: I can change my password
Given this is a pending scenario
Scenario: I can generate a new token
Given this is a pending scenario
Scenario: I can edit preferences
Given this is a pending scenario