Permalink
Browse files

Give present se pasa al modelo de operations

  • Loading branch information...
1 parent 369fffb commit 98d4ec67039b9cf49d4c1c60472cf78baf1f8b0d @juanpabloe committed Nov 21, 2011
@@ -25,21 +25,6 @@ $(document).ready(function() {
})
});
-
-
- /*$(".tab-content").hide();
- $("#alumnos").show();
- //Change tabs in search view
- $('a',"#groupby-tabs").click(function(e) {
- e.preventDefault();
- $("#groupby-tabs a").removeClass("ui-btn-active");
- $(this).addClass("ui-btn-active");
- $(".tab-content").hide();
- var activeTab = $(this).attr("href");
- $(activeTab).show();
- return false;
- });*/
-
//Confirmation box student donation form
$('.present').live('vclick', function() {
$(this).simpledialog({
@@ -91,19 +76,19 @@ function mandaRegalo(premio) {
if (premio > 0 && premio < 5) {
switch(premio) {
case 1:
- $("#donation_amount").val(10);
+ $("#operation_amount").val(10);
$("#new_operation").submit();
break;
case 2:
- $("#donation_amount").val(20);
+ $("#operation_amount").val(20);
$("#new_operation").submit();
break;
case 3:
- $("#donation_amount").val(30);
+ $("#operation_amount").val(30);
$("#new_operation").submit();
break;
case 4:
- $("#donation_amount").val(50);
+ $("#operation_amount").val(50);
$("#new_operation").submit();
break;
default:
@@ -18,6 +18,15 @@ def new
end
end
+ def give_present
+ @student = Student.find(params[:to_student])
+ if is_bday?(@student)
+ @operation = Operation.new(:op_type => "donation")
+ else
+ redirect_to menu_students_path
+ end
+ end
+
def create
@operation = Operation.new(params[:operation])
to_user = Student.find(params[:operation][:to_user_id])
@@ -19,15 +19,6 @@ def ranking
def menu
end
-
- def give_present
- @student = Student.find(params[:id])
- if is_bday?(@student)
- @donation = Donation.new
- else
- redirect_to menu_students_path
- end
- end
private
@@ -4,7 +4,7 @@
<ul data-role="listview" data-theme="c">
<% if @notifications %>
<% @notifications.each do |student| %>
- <li><%= link_to "#{student.complete_name}", give_present_student_path(student.id)%></li>
+ <li><%= link_to "#{student.complete_name}", give_present_user_operations_path(current_user, :to_student => student.id) %></li>
<% end %>
<% else %>
<li>No hay notificaciones</li>
@@ -23,9 +23,10 @@
</div>
</div>
-<%= form_for @donation, :url => donate_student_path(@student) do |f| %>
+<%= form_for @operation, :url => { :action => :create } do |f| %>
<%= f.hidden_field :amount %>
<%= f.hidden_field :description, :value=>'Regalo!!!' %>
<%= f.hidden_field :to_user_id, :value => @student.id %>
+ <%= f.hidden_field :op_type, :value => @operation.op_type %>
<% end %>
View
@@ -11,10 +11,13 @@
root :to => "sessions#new"
resources :users do
- resources :operations
+ resources :operations do
+ collection do
+ get "give_present"
+ end
+ end
member do
get "history"
- get "history_full"
end
end
resources :sessions
@@ -27,21 +30,6 @@
collection do
get "ranking"
get "menu"
- get "list_multiple"
- post "donate_multiple"
- get "multiple_donation"
- end
- member do
- get "make_donation"
- get "make_withdraw"
- get "give_present"
- post "donate"
- post "withdraw"
end
end
- resources :donations do
- collection do
- post "multiple"
- end
- end
end

0 comments on commit 98d4ec6

Please sign in to comment.