Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Ajout des heures par membre #4

Merged
merged 4 commits into from

3 participants

@EtienneDepaulis

Ajout des heures pour chaque membre de la Cordée sur le même principe de fonctionnement que pour la remplitude (MAJ toutes les 12 heures de l'intégralité des membres).

/!\ IMPORTANT /!\ : tout comme "bundle exec rake update_remplitude" n'a pas l'air de fonctionner en DEV, "bundle exec rake update_heures" ne fonctionne pas non plus. L'affichage des heures a donc été testé mais pas la MAJ (pas le temps de comprends pourquoi les taches rakes ne tournent pas ...)

@pcreux pcreux commented on the diff
lib/tasks/update_heures.rake
@@ -0,0 +1,20 @@
+task :update_heures => :environment do
+
+ # Update remplitude asking gardien API
+ $conf = Conf.find(1)
+
+ puts "Updating heures..."
+ begin
+ Gardien::Members.all.each do |member|
+ this_member = Member.find_by_refuge_id(member.id)
+
+ this_member.update_attributes({:total_heures_guardien => member.total_hours, :total_heures_facturable_guardien => member.billable_hours, :debut_mois_gardien => member.since}) if this_member
@pcreux
pcreux added a note

use update_attributes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pcreux pcreux commented on the diff
lib/tasks/update_heures.rake
@@ -0,0 +1,20 @@
+task :update_heures => :environment do
+
+ # Update remplitude asking gardien API
+ $conf = Conf.find(1)
+
+ puts "Updating heures..."
+ begin
+ Gardien::Members.all.each do |member|
+ this_member = Member.find_by_refuge_id(member.id)
+
+ this_member.update_attributes({:total_heures_guardien => member.total_hours, :total_heures_facturable_guardien => member.billable_hours, :debut_mois_gardien => member.since}) if this_member
+ end
+ rescue
+ # Oooops, gardien is down
+ puts "!!! HEURES UPDATE FAILED !!!"
@pcreux
pcreux added a note

Yey, silent failure! @Guillaume: tu pourrais t'installer un serveur errbit pour être tenu au courant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@pcreux pcreux commented on the diff
app/views/widgets/_refuge.html.haml
@@ -0,0 +1,10 @@
+-if current_member.total_heures_guardien > 0
+ #refuge
+ %p
+ Présence :
+ ="#{current_member.total_heures_guardien.round} h"
@pcreux
pcreux added a note

bon, je suis sympa, je fais en sorte que gardien vous envoie des valeurs par défaut. Parce-que oui, il aurait pu vous envoyer des "null" et là, ça aurait fait boom!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@gbarillot gbarillot merged commit 4b52817 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
1  Gemfile
@@ -30,6 +30,7 @@ gem 'acts_as_tree_rails3'
gem 'birthday', '~> 0.2.0'
gem 'multi_json'
gem 'whenever'
+gem 'rails-i18n'
group :development, :test do
# Pretty printed test output
View
3  Gemfile.lock
@@ -146,6 +146,8 @@ GEM
activesupport (= 3.1.1)
bundler (~> 1.0)
railties (= 3.1.1)
+ rails-i18n (0.7.0)
+ i18n (~> 0.5)
railties (3.1.1)
actionpack (= 3.1.1)
activesupport (= 3.1.1)
@@ -237,6 +239,7 @@ DEPENDENCIES
mysql2
rack-cache
rails (= 3.1.1)
+ rails-i18n
rmagick
rspec-rails
sass-rails!
View
1  app/views/ads/_right_column.html.haml
@@ -1,3 +1,4 @@
+= render :partial => '/widgets/refuge'
= render :partial => '/widgets/occupation'
= render :partial => '/widgets/last_updated_users', :locals => {:users => User.new_comers, :direction => :users_incoming}
= render :partial => '/widgets/surveys'
View
3  app/views/members/edit.html.haml
@@ -162,6 +162,9 @@
%select{:name=>'user[role]', :style=>'margin-right:20px;'}
%option{:value=>'user', :selected => @member.user.role == 'user'}= 'User'
%option{:value=>'admin', :selected => @member.user.role == 'admin'}= 'Admin'
+ .span4.right
+ = t('refuge_id')
+ = f.text_field :refuge_id
.span11
= submit_tag t(:save), :class=>'btn btn-warning', :style=>'float:right; margin-right:20px;'
View
10 app/views/widgets/_refuge.html.haml
@@ -0,0 +1,10 @@
+-if current_member.total_heures_guardien > 0
+ #refuge
+ %p
+ Présence :
+ ="#{current_member.total_heures_guardien.round} h"
@pcreux
pcreux added a note

bon, je suis sympa, je fais en sorte que gardien vous envoie des valeurs par défaut. Parce-que oui, il aurait pu vous envoyer des "null" et là, ça aurait fait boom!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ =" (#{current_member.total_heures_facturable_guardien.round} h facturées)"
+ %br
+ %small
+ depuis le
+ =current_member.debut_mois_gardien.strftime("%d/%m/%Y")
View
1  config/locales/en.yml
@@ -55,6 +55,7 @@ fr:
references: "My references"
hobbies: "My hobbies"
powers: "My super-powers"
+ refuge_id: "ID Refuge"
presence: "You can see me more likely"
cordee_location: "Member of "
new_account_creation: "New member creation"
View
1  config/locales/fr.yml
@@ -87,6 +87,7 @@ fr:
references: "Mes réferences"
hobbies: "Mes loisirs"
powers: "Super-pouvoirs"
+ refuge_id: "ID Refuge"
presence: "Je suis plutôt à la Cordée"
cordee_location: "Membre de la cordée"
new_account_creation: "Création d'un nouveau membre"
View
4 config/schedule.rb
@@ -21,4 +21,8 @@
every 15.minutes do
rake "update_remplitude RAILS_ENV='production'"
+end
+
+every 12.hours do
+ rake "update_heures RAILS_ENV='production'"
end
View
7 db/migrate/20121212085626_add_gardiens_infos_to_members.rb
@@ -0,0 +1,7 @@
+class AddGardiensInfosToMembers < ActiveRecord::Migration
+ def change
+ add_column :members, :total_heures_guardien, :float
+ add_column :members, :total_heures_facturable_guardien, :float
+ add_column :members, :debut_mois_gardien, :date
+ end
+end
View
10 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20121130144136) do
+ActiveRecord::Schema.define(:version => 20121212085626) do
create_table "ads", :force => true do |t|
t.string "subject"
@@ -99,6 +99,7 @@
t.datetime "updated_at", :null => false
t.integer "max_occupation", :default => 20
t.integer "refuge_id"
+ t.integer "remplitude", :default => 0
end
add_index "locations", ["refuge_id"], :name => "index_locations_on_refuge_id"
@@ -125,7 +126,7 @@
create_table "members", :force => true do |t|
t.integer "user_id"
- t.string "first_name", :default => "anonyme"
+ t.string "first_name", :default => "anonyme"
t.string "last_name"
t.date "birthday"
t.string "city"
@@ -146,9 +147,12 @@
t.text "website_2"
t.text "mobile"
t.boolean "www_published"
- t.boolean "is_active", :default => true, :null => false
+ t.boolean "is_active", :default => true, :null => false
t.string "logo_uid"
t.integer "refuge_id"
+ t.float "total_heures_guardien"
+ t.float "total_heures_facturable_guardien"
+ t.date "debut_mois_gardien"
end
add_index "members", ["refuge_id"], :name => "index_members_on_refuge_id"
View
20 lib/tasks/update_heures.rake
@@ -0,0 +1,20 @@
+task :update_heures => :environment do
+
+ # Update remplitude asking gardien API
+ $conf = Conf.find(1)
+
+ puts "Updating heures..."
+ begin
+ Gardien::Members.all.each do |member|
+ this_member = Member.find_by_refuge_id(member.id)
+
+ this_member.update_attributes({:total_heures_guardien => member.total_hours, :total_heures_facturable_guardien => member.billable_hours, :debut_mois_gardien => member.since}) if this_member
@pcreux
pcreux added a note

use update_attributes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ end
+ rescue
+ # Oooops, gardien is down
+ puts "!!! HEURES UPDATE FAILED !!!"
@pcreux
pcreux added a note

Yey, silent failure! @Guillaume: tu pourrais t'installer un serveur errbit pour être tenu au courant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ # !!! TODO : notice admin
+ end
+
+
+end
Something went wrong with that request. Please try again.