Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions app/assets/javascripts/modules/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ jQuery(document).ready(function($){
}
});

// Prevent Enter key to click on the first button of the form, which is the link to the
// other form only when the trackdon modal form is visible
$(document).keydown(function(event){
if(event.which=='13'){
if( $('form[id="new_donation"]').parents("#modal-track").hasClass('.is-visible') ){
event.preventDefault();
$('form:visible').submit();
}
}
});

//close modal when clicking the esc keyboard button
$(document).keyup(function(event){
event.preventDefault();
Expand Down
7 changes: 4 additions & 3 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
@import "objects/justify-columns";
@import "objects/content";
@import "objects/modal";
@import "objects/headings";

/*
* 5. Layout
Expand Down Expand Up @@ -186,7 +187,7 @@ form.simple_form input[type='checkbox'] { width: auto; }
form.simple_form textarea { height: 100px; }
form.simple_form input[type='submit'] { width: 40%;}

.alert { background: #EBE8CC; padding-top: 1em; padding-bottom: 1em; margin-bottom: 2em; }
.alert { background: $light_background; padding-top: 1em; padding-bottom: 1em; margin-bottom: 2em; }
.success, .info, .warning, .danger { }
#main_content > .alert {
padding-left: 5%;
Expand All @@ -206,8 +207,8 @@ td {
#logo { position: absolute; top: 0; width: 100px; height: 100%; text-align: center; vertical-align: middle; font-weight: 700}
#logo a { display: block; padding: 12px 8px; font-size: 13px; text-decoration: none; text-transform: uppercase; }
h1.logo { background: $secondary-color; text-transform: uppercase; display: inline-block; padding: 8px 16px; color: #FFF; font-size: 24px; font-weight: normal; }
h1 { font-size: 32px; }
h2 { font-size: 24px; }
// h1 { font-size: 32px; }
// h2 { font-size: 24px; }
#header { font-size: 14px;}
#header ul { margin: 0; padding: 0; }
#header ul li { list-style-type: none; display: inline-block; margin-right: 4px }
Expand Down
6 changes: 4 additions & 2 deletions app/assets/stylesheets/layout/_donations.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
c/*
*
* Donation object
* ---------------
Expand Down Expand Up @@ -63,7 +63,7 @@
color: $secondary_color;
font-size: 1em;
color: #666;
margin: 0 10px 10px 0;
margin: 0 10px 10px 40px;
border: none;

.date {
Expand All @@ -82,6 +82,8 @@
h2 {
font-size: 1.1em;
font-weight: normal;
color: $secondary_color;
border: none;
}
.donation {
margin-top: 1em;
Expand Down
9 changes: 0 additions & 9 deletions app/assets/stylesheets/layout/_user-profile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@
top: 0;
left: 0;
}

h2 {
color: $main-color;
border-bottom: 2px solid $main-color;
border-top: none;
padding: 0 0 .15em 0;
font-size: 1.1em;
}

.counters {
h2 {
border: none;
Expand Down
5 changes: 5 additions & 0 deletions app/assets/stylesheets/objects/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ a.btn.not_active:hover {
color: #FFF;
border: none;
}
}
.notice-box {
border-radius: 4px;
background: $light_background;
font-size: .85em;
}
6 changes: 3 additions & 3 deletions app/assets/stylesheets/objects/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ This object is the column holding the content of the page. There are a few flavo
padding-right: 5%;

@include min-screen(880) {
padding-left: 20px;
padding-right: 20px;
width: 710px;
// padding-left: 20px;
// padding-right: 20px;
// width: 710px;
}
}

Expand Down
7 changes: 7 additions & 0 deletions app/assets/stylesheets/objects/_headings.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
h2 {
color: $main-color;
border-bottom: 2px solid $main-color;
border-top: none;
padding: 0 0 .15em 0;
font-size: 1.1em;
}
3 changes: 3 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@ def modal_error(flash_type, message)
flash["modal_#{flash_type}_error".to_sym] = message
end

def set_current_external_services
@current_external_services = ExternalServiceManager.new(current_user)
end
end
17 changes: 16 additions & 1 deletion app/controllers/donations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ class DonationsController < ApplicationController

before_action :logged_in_user, only: [:edit, :update, :destroy]
before_action :load_user_donation, only: [:edit, :complete, :update, :destroy]
before_action :set_current_external_services, only: [:index]

def index
@donations = Donation.includes(:project, :user).sorted
@donations = fetch_donations.includes(:project, :user).sorted
@featured_donations = @donations.featured.limit(5)
end

def show
Expand Down Expand Up @@ -40,6 +42,19 @@ def destroy

private

def fetch_donations
donations = Donation
@donations_from_everybody = true

if logged_in? && current_user.following_users_count > 0
friends_ids = current_user.following_users.pluck(:id)
donations = donations.from_users(friends_ids)
@donations_from_everybody = false
end

donations
end

def donation_params
params.require(:donation).permit(:quantity, :currency, :date, :comment, :quantity_privacy, :show_comment, :recurring,
:project_id, project_attributes: [:name, :description, :url, :id, :category_id])
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/external_authentications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,4 @@ def set_user
@user = current_user
end

def set_current_external_services
@current_external_services = ExternalServiceManager.new(current_user)
end

end
2 changes: 2 additions & 0 deletions app/models/donation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Donation < ActiveRecord::Base
scope :quantity_private, -> { where(quantity_privacy: true) }
scope :sorted, -> { order(date: :desc) }
scope :last_month, -> { where('date >= ?', 1.month.ago) }
scope :from_users, ->(users_ids) { where(user_id: users_ids) }
scope :featured, -> { where("char_length(comment) > 134 ") }

validates :project_id, presence: true
validates :user_id, presence: true
Expand Down
9 changes: 4 additions & 5 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class User < ActiveRecord::Base
has_secure_password validations: false

has_many :donations, dependent: :destroy
has_many :recurring_donations, dependent: :destroy
has_many :projects, through: :donations
has_many :invitations

Expand Down Expand Up @@ -76,10 +75,6 @@ def send_password_reset_email
UserMailer.password_reset(self).deliver_now
end

def has_private_donations?
donations.quantity_private.any?
end

def generate_password_reset_token!
generate_token(:password_reset_token)
save!
Expand All @@ -89,6 +84,10 @@ def invitation
self.invitation_token.present? && Invitation.find_valid_token(self.invitation_token)
end

def all_external_services_connected?
twitter_id.present? && facebook_id.present?
end

private

def set_currency
Expand Down
16 changes: 16 additions & 0 deletions app/views/donations/_connect_with_friends.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="notice-box mb4 px4 py1">
<p><%= t('.connect_with_facebook_and_twitter') %></p>
<p><%= t('.never_publish') %></p>

<% css_classes = ['float-left', 'float-right'] %>

<div class="social-login mt2 mb3 clearfix">
<% if !@current_external_services.include?(:twitter) %>
<%= link_to(t('.twitter'), '/auth/twitter', class: "btn #{css_classes.shift}") %>
<% end %>

<% if !@current_external_services.include?(:facebook) %>
<%= link_to(t('.facebook'), '/auth/facebook', class: "btn #{css_classes.shift}") %>
<% end %>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/donations/_donation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<% end %>
</h3>

<%= render partial: 'donations/donation_do_widget', locals: {donation: donation} %>
<%# render partial: 'donations/donation_do_widget', locals: {donation: donation} %>

<% if donation.comment.present? && !in_complete_donation_page? %>
<div class="donation_comment mb2">
Expand Down
8 changes: 8 additions & 0 deletions app/views/donations/_post_in_social_networks.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="notice-box px4 py1">
<p><%= t('.no_friends_activity') %></p>

<div class="social-login mt2 mb3 clearfix">
<%= link_to(t('.twitter'), 'https://twitter.com', class: "btn mr2 ") %>
<%= link_to(t('.facebook'), 'https://facebook.com', class: "btn ") %>
</div>
</div>
36 changes: 31 additions & 5 deletions app/views/donations/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
<% set_meta_tags :description => t('metas.donations.home.description') %>

<section class="content_column">
<section class="donations wide_content">

<h1><%= title t('metas.donations.home.title') %></h1>
<div class="main_column left">

<% @donations.each do |donation| %>
<%= render partial: 'donation', locals: {donation: donation} %>
<% end %>
<h1><%= title t('metas.donations.home.title') %></h1>

<% if logged_in? %>
<% if @donations_from_everybody %>
<% if current_user.all_external_services_connected? %>
<%= render 'post_in_social_networks' %>
<p><%= t('.donations_everybody') %></p>
<% else %>
<%= render 'connect_with_friends' %>
<% end %>
<% end %>
<% end %>

<% @donations.each do |donation| %>
<%= render partial: 'donation', locals: {donation: donation} %>
<% end %>
</div>

<div class="sidebar right">

<% if @featured_donations.any? %>
<h2><%= t('.featured_donations') %></h2>

<% @featured_donations.each do |donation| %>
<%= render partial: 'donation', locals: {donation: donation} %>
<% end %>
<% end %>

</div>

</section>
5 changes: 3 additions & 2 deletions app/views/shared/_modal_login.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</div>

<div id="cd-login" >

<%= modal_flash_message(:login) %>

<p><%= t 'sessions.new.or_choose_tradition' %></p>
Expand All @@ -42,7 +43,7 @@
</div>

<div class="clearfix mt3 pb4">
<%= f.button t('sessions.new.create_account'), class: "btn btn-secondary float-left create-account", tabindex: 4 %>
<%= link_to t('sessions.new.create_account'), '', class: "btn btn-secondary float-left create-account", tabindex: 4 %>
<%= f.submit t('sessions.new.login_action'), class: "btn btn-primary float-right", tabindex: 3 %>
</div>

Expand Down Expand Up @@ -100,7 +101,7 @@
<%= f.hidden_field :invitation_token, value: params[:invitation_token] %>

<div class="clearfix mt3 pb4">
<%= f.button t('sessions.new.already_have_account'), class: "btn btn-secondary float-left login" %>
<%= link_to t('sessions.new.already_have_account'), '', class: "btn btn-secondary float-left login" %>
<%= f.submit t('sessions.new.create_account'), class: "btn btn-primary float-right" %>
</div>
<% end %>
Expand Down
12 changes: 12 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ en:
complete:
great_just_one_thing: 'Great! Just one thing before you are done:'
tell_why_you_have_donated: 'Tell why you have donated, that will make the most impact in your friends and recruit more donors for the project.'
connect_with_friends:
connect_with_facebook_and_twitter: "Connect with Facebook and Twitter to see your friend's activity"
never_publish: 'We never publish without your permission, we hate it!'
facebook: Facebook
twitter: Twitter
index:
donations_everybody: 'Donations from everybody:'
featured_donations: Featured donations
post_in_social_networks:
no_friends_activity: 'None of your friends have yet tracked any donation. Post about your donations in Twitter and Facebook so they get inspired!'
twitter: Twitter
facebook: Facebook
# donations form
how_much_question: 'How much?'
when_did_you_donate: 'When did you donate?'
Expand Down
13 changes: 13 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ es:
complete:
great_just_one_thing: 'Genial! Solo una cosita más: '
tell_why_you_have_donated: 'Explica por qué has donado, eso tendrá el mayor impacto en tus amigos y reclutarás a más donantes para el projecto.'
connect_with_friends:
connect_with_facebook_and_twitter: "Conecta con Facebook y Twitter para ver la actividad de tus amigos"
never_publish: 'Nunca publicaremos nada sin tu permiso, ¡lo odiamos!'
facebook: Facebook
twitter: Twitter
index:
featured_donations: Donaciones destacadas
donations_everybody: 'Donaciones de todo el mundo:'
post_in_social_networks:
no_friends_activity: 'None of your friends have yet tracked any donation. Post about your donations in Twitter and Facebook so they get inspired!'
no_friends_activity: 'Ninguno de tus amigos ha guardado una donación aún. ¡Postea sobre tus donaciones en Facebook y Twitter para que se inspiren!'
twitter: Twitter
facebook: Facebook
how_much_question: '¿Cuánto?'
when_did_you_donate: '¿Cuándo donaste?'
i_want_to_explain_why: 'Quiero explicar por qué he donado para animar a otros'
Expand Down
9 changes: 5 additions & 4 deletions spec/features/last_donations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@

visit donations_page

expect(page).to have_css('.donation:nth-child(2)', text: 'Bruce donated to Wikiwadus # Mar 01 2015')
expect(page).to have_css('.donation:nth-child(3)', text: 'Yorch donated to Wikiwadus # Jan 01 2015')
expect(page).to have_css('.donation:nth-child(4)', text: 'Bruce donated to Gnome # Feb 01 2014')
expect(page).to have_css('.donation:nth-child(5)', text: 'Yorch donated to Gnome # Jan 01 2014')
donations = page.all(:css, '.donation')
expect(donations[0].text).to start_with('Bruce donated to Wikiwadus # Mar 01 2015')
expect(donations[1].text).to start_with('Yorch donated to Wikiwadus # Jan 01 2015')
expect(donations[2].text).to start_with('Bruce donated to Gnome # Feb 01 2014')
expect(donations[3].text).to start_with('Yorch donated to Gnome # Jan 01 2014')
end
end