Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: martinvega/dtv
base: 1d0e7b915c
...
head fork: martinvega/dtv
compare: 272a43c39c
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 12 files changed
  • 0 commit comments
  • 1 contributor
View
1  app/assets/javascripts/common.js.coffee
@@ -5,6 +5,7 @@ $ ->
$(document).ready ->
$('#datepicker').datepicker({dateFormat: 'dd-mm-yy'})
+ $('#campaign_picker').datepicker({dateFormat: 'dd-mm-yy'})
$('#state_select').click ->
if (($("#state_select option:selected").text() == 'RE LLAMAR') || ($("#state_select option:selected").text() == 'RETENIDO') || ($("#state_select option:selected").text() == 'RETENIDO X CICLO') || ($("#state_select option:selected").text() == 'RENOVACIÓN'))
View
31 app/controllers/contacts_controller.rb
@@ -86,28 +86,33 @@ def update
end
end
- def find_contact
- contact = Contact.where(:contact_state_id => nil).first!
-
- rescue ActiveRecord::RecordNotFound
- flash[:alert] = 'No quedan mas contactos por cargar, todos ya cuentan con un
- estado asignado'
- redirect_to contacts_path
- end
-
def load_contacts
- @contact = Contact.find((find_contact).id)
+
+ unless params[:campaign].nil?
+ @campaign = Campaign.find(params[:campaign])
+ @selected = @campaign.id
+ date = @campaign.date
+ contact = Contact.where('contact_state_id IS NULL AND date BETWEEN :start AND :end',
+ :start => date.beginning_of_month,
+ :end => date.end_of_month).first!
+ @contact = Contact.find(contact.id)
+ end
+
+ rescue ActiveRecord::RecordNotFound
+ flash[:alert] = 'No quedan mas contactos por cargar para la campaña seleccionada'
+ redirect_to contacts_path
+
end
def update_state
@contact = Contact.find(params[:id])
- @contact.user = @auth_user
-
+
respond_to do |format|
if @contact.update_attributes(params[:contact])
+ @contact.user = @auth_user
format.html {
flash[:notice] = 'El estado ha sido guardado satisfactoriamente,
- puede continuar con la carga'
+ presione Buscar Contacto para continuar con la carga'
render :action => :load_contacts }
format.json { head :ok }
else
View
7 app/models/campaign.rb
@@ -1,10 +1,7 @@
class Campaign < ActiveRecord::Base
# Validaciones
- validates :month, :year, :presence => true
- validates_numericality_of :month, :only_integer => true, :greater_than => 0,
- :less_than => 13, :allow_nil => true, :allow_blank => true
- validates_numericality_of :year, :only_integer => true, :greater_than => 1990,
- :less_than => 2050, :allow_nil => true, :allow_blank => true
+ validates :date, :presence => true
+ validates_date :date, :allow_nil => true, :allow_blank => true
end
View
2  app/models/contact.rb
@@ -14,5 +14,5 @@ class Contact < ActiveRecord::Base
:allow_blank => true, :greater_than => 0, :less_than => 5000000
validates_uniqueness_of :number, :allow_nil => true, :allow_blank => true
validates_date :date, :allow_nil => true, :allow_blank => true
-
+
end
View
9 app/views/campaigns/_form.html.erb
@@ -11,13 +11,10 @@
<% end %>
<div class="field">
- <%= f.label :month %><br />
- <%= f.number_field :month %>
- </div>
- <div class="field">
- <%= f.label :year %><br />
- <%= f.number_field :year %>
+ <%= f.label :date %><br />
+ <%= f.text_field :date, :id => 'campaign_picker' %>
</div>
+
<div class="actions">
<%= f.submit %>
</div>
View
6 app/views/campaigns/index.html.erb
@@ -1,7 +1,6 @@
<table>
<tr>
- <th><%= Campaign.human_attribute_name 'month' %></th>
- <th><%= Campaign.human_attribute_name 'year' %></th>
+ <th><%= Campaign.human_attribute_name 'date' %></th>
<th></th>
<th></th>
<th></th>
@@ -9,8 +8,7 @@
<% @campaigns.each do |campaign| %>
<tr class="<%= cycle(:even, :odd) %>">
- <td><%= campaign.month %></td>
- <td><%= campaign.year %></td>
+ <td><%= campaign.date %></td>
<td><%= link_to 'Ver', campaign %></td>
<td><%= link_to 'Editar', edit_campaign_path(campaign) %></td>
<td class ="delete"><%= button_to 'Eliminar', campaign, :confirm => '¿Estás seguro?',
View
9 app/views/campaigns/show.html.erb
@@ -1,11 +1,6 @@
<p>
- <b><%= Campaign.human_attribute_name 'month' %>:</b>
- <%= @campaign.month %>
-</p>
-
-<p>
- <b><%= Campaign.human_attribute_name 'year' %>:</b>
- <%= @campaign.year %>
+ <b><%= Campaign.human_attribute_name 'date' %>:</b>
+ <%= @campaign.date %>
</p>
View
47 app/views/contacts/_contact.html.erb
@@ -0,0 +1,47 @@
+<div id="load_contact">
+<%= form_for @contact, :url => {:controller => :contacts,
+ :action => :update_state, :id => @contact.id} do |f| %>
+ <% if @contact.errors.any? %>
+ <div id="error_explanation">
+ <h2>El Contacto no se pudo guardar por los siguientes errores:</h2>
+
+ <ul>
+ <% @contact.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+ <div class="field">
+ <%= f.label 'Fecha' %><br />
+ <%= f.text_field :date, :disabled => true %>
+ </div>
+ <div class="field">
+ <%= f.label 'Nombre' %><br />
+ <%= f.text_field :name, :disabled => true %>
+ </div>
+ <div class="field">
+ <%= f.label 'Número' %><br />
+ <%= f.number_field :number, :disabled => true %>
+ </div>
+ <div class="field">
+ <%= f.label 'Localidad' %><br />
+ <%= f.text_field :locality, :disabled => true %>
+ </div>
+ <div class="field">
+ <%= f.label 'Estado' %><br />
+ <div id ="state_select">
+ <%= f.collection_select :contact_state_id, ContactState.all, :id,
+ :state, :prompt => 'Seleccione el estado' %>
+ </div>
+ </div>
+ <div class="comment" style ="display: none;">
+ <%= f.label 'Comentario' %><br />
+ <%= f.text_area :comment, :size => '35x5' %>
+ </div>
+
+ <div lass="actions">
+ <%= f.submit 'Guardar Contacto' %>
+ </div>
+<% end %>
+</div>
View
60 app/views/contacts/load_contacts.html.erb
@@ -1,54 +1,20 @@
-<div id="load_contact">
-<%= form_for @contact, :url => {:controller => :contacts,
- :action => :update_state, :id => @contact.id} do |f| %>
- <% if @contact.errors.any? %>
- <div id="error_explanation">
- <h2>El Contacto no se pudo guardar por los siguientes errores:</h2>
+<% unless @contact.nil? %>
+ <%= render :partial => 'contact' %>
+<% end %>
+
+<%= form_tag load_contacts_contacts_path, :method => 'get' do %>
- <ul>
- <% @contact.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
- <div class="field">
- <%= f.label 'Fecha' %><br />
- <%= f.text_field :date, :disabled => true %>
- </div>
- <div class="field">
- <%= f.label 'Nombre' %><br />
- <%= f.text_field :name, :disabled => true %>
- </div>
- <div class="field">
- <%= f.label 'Número' %><br />
- <%= f.number_field :number, :disabled => true %>
- </div>
- <div class="field">
- <%= f.label 'Localidad' %><br />
- <%= f.text_field :locality, :disabled => true %>
- </div>
<div class="field">
- <%= f.label 'Estado' %><br />
- <div id ="state_select">
- <%= f.collection_select(:contact_state_id, ContactState.all, :id,
- :state, :prompt => 'Seleccione el estado') %>
- </div>
- </div>
- <div class="comment" style ="display: none;">
- <%= f.label 'Comentario' %><br />
- <%= f.text_area :comment, :size => '35x5' %>
- </div>
-
- <div lass="actions">
- <%= f.submit 'Guardar Contacto' %>
+ <%= select_tag :campaign,
+ options_from_collection_for_select(Campaign.all, "id", "date", @selected) %>
+
</div>
-<% end %>
-
-</div>
<div id="links">
<div id="search_contact">
- <%= link_to 'Buscar Contacto', load_contacts_contacts_path, :class => :important_action %>
+ <%= submit_tag 'Buscar Contacto' %>
</div>
-</div>
+</div>
+
+ <% end %>
+
View
3  config/locales/es.yml
@@ -39,8 +39,7 @@ es:
attributes:
campaign:
- month: 'Mes'
- year: 'Año'
+ date: 'Fecha'
contact:
date: 'Fecha'
name: 'Nombre'
View
7 db/migrate/20120322215345_add_date_to_campaigns.rb
@@ -0,0 +1,7 @@
+class AddDateToCampaigns < ActiveRecord::Migration
+ def change
+ remove_column :campaigns, :month
+ remove_column :campaigns, :year
+ add_column :campaigns, :date, :date
+ end
+end
View
5 db/schema.rb
@@ -10,13 +10,12 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120316220458) do
+ActiveRecord::Schema.define(:version => 20120322215345) do
create_table "campaigns", :force => true do |t|
- t.integer "month"
- t.integer "year"
t.datetime "created_at"
t.datetime "updated_at"
+ t.date "date"
end
create_table "contact_states", :force => true do |t|

No commit comments for this range

Something went wrong with that request. Please try again.