-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from doxa-tech/v2/cards-update-check
Adds email for cards update checks
- Loading branch information
Showing
23 changed files
with
359 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# This script should be placed in /etc/cron.daily to check the cards status | ||
# every day and send an email to the card's owner accordingly. | ||
|
||
set -e | ||
|
||
setuser app bundle exec rake cards_update:check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<% content_for :prehead, "Un groupe est désactivé sur Réseau Jeunesse" %> | ||
|
||
<h1>Le groupe: <%= @card.name %></h1> | ||
|
||
<p>... est désormais désactivé.</p> | ||
|
||
<%= render "mailers/button_center" do %> | ||
<%= link_to "Voir le groupe", edit_admin_card_url(@card), target: "_blank" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<h1>Ton groupe <%= @card.name %> est-il encore à jour ?</h1> | ||
|
||
<p>Voilà <b><%= time_ago_in_words(@card.last_updated) %></b> que ton groupe sur Réseau Jeunesse n'a pas été mis à jour. | ||
<% if @step >= 4 %> | ||
<b>Ton groupe est maintenant désactivé, il faut impérativement le vérifier et/ou le mettre à jour</b>. | ||
<% end %> | ||
</p> | ||
|
||
<p>Afin de garder des informations valides, nous te demandons de vérifier et mettre à jour si nécessaire les informations de ton groupe. | ||
Cette étape est nécessaire pour garder ton groupe sur le site.</p> | ||
|
||
<%= render "mailers/button_center" do %> | ||
<%= link_to "Confirmer / Mettre à jour mon groupe", edit_users_card_url(@card, confirm:true), "_target"=>"_blank" %> | ||
<% end %> | ||
|
||
<p>Tu peux changer en tout temps les informations de ton groupe à partir de | ||
<%= link_to "ton compte", profile_url, target: "_blank" %> sur le site. Tu recevras tous les 6 mois une invitation à contrôler les informations de ton groupe.</p> | ||
|
||
<% if @step == 1 %> | ||
<p>Ceci est le premier rappel.</p> | ||
<% elsif @step > 1 && @step <= 2 %> | ||
<p>Ceci est le <%= @step %>e rappel.</p> | ||
<% elsif @step == 3 %> | ||
<p>Ceci est le <%= @step %>e rappel.<br><b>Attention: le groupe sera désactivé dans 2 semaines s'il n'est pas mis à jour</b>.</p> | ||
<% elsif @step >= 4 %> | ||
<p>Ceci est le <%= @step %>e rappel. <b>Nous nous réservons le droit de supprimer ton groupe si aucune action n'est entreprise</b>.</p> | ||
<% end %> | ||
|
||
<p>Tu peux en savoir plus sur notre politque de mise à jour des groupes <a href="https://reseaujeunesse.ch/faq#update_groups" target="_blank">via notre FAQ</a>.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div data-controller="popup"> | ||
<div class="standard-popup active" data-popup-target="content"> | ||
<div class="content"> | ||
|
||
<p>Merci d'avoir confirmé ton groupe. Aucune autre action de ta part n'est nécessaire.</p> | ||
|
||
<div class="buttons"> | ||
<button class="cancel" type="button" data-action="popup#close">Fermer</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div data-controller="popup"> | ||
<div class="standard-popup active" data-popup-target="content"> | ||
<div class="content"> | ||
|
||
<p>Merci de vérifier (et mettre à jour si nécessaire) les informations de ton groupe.</p> | ||
<p>Quand tu as fini, clique sur le bouton <b>"Sauvegarder et mettre à jour"</b>, même si tu n'a fait aucun changement.</p> | ||
|
||
<div class="buttons"> | ||
<button class="cancel" type="button" data-action="popup#close">Fermer</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddValidityToCards < ActiveRecord::Migration[6.0] | ||
def change | ||
add_column :cards, :validity, :integer, default: 0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Feature: Confirm the validity of a card | ||
|
||
So that my card is not disabled | ||
as the owner | ||
I want to update the card | ||
|
||
Background: | ||
Given I am a confirmed user | ||
And I am signed in | ||
|
||
Scenario: The card is up-to-date | ||
Given I have a complete card | ||
When I visit the card's update page | ||
Then I should not see "Merci de vérifier" | ||
|
||
Scenario: The owner received a request to confirm the card | ||
Given I have a card that must be confirmed | ||
When I visit the card's update page | ||
Then I should see "Merci de vérifier" | ||
|
||
Scenario: I update an card after a request | ||
Given I have a card that must be confirmed | ||
When I visit the card's update page | ||
And I click the button "Sauvegarder et mettre à jour" | ||
Then I should see "Merci d'avoir confirmé ton groupe" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
namespace :cards_update do | ||
|
||
desc "Check if a card must be checked by its owner" | ||
task check: :environment do | ||
Card.all.each do |card| | ||
# Here is the schedule reminder: | ||
# | ||
# | Step | Days | | ||
# | ---- | ---- | | ||
# | 0 | 180 | | ||
# | 1 | 180 + 14 | | ||
# | 2 | 180 + 14*2 | | ||
# | 3 | 180 + 14*3 | | ||
# | 4 | 180 + 14*4 | // deactivate the card | ||
# | 5 | 180 + 14*4 + 60 | | ||
# | 5 +i | 180 + 14*4 + 60 * (i+1) | // send every two months | ||
|
||
# to be fair we cap the last_updated to the release of V2 - 6 months to be | ||
# adjusted so that when we release the task we quickly get 180 days. To be | ||
# removed once all cards have received their warnings. | ||
release = Date.strptime("4/7/2021", "%d/%m/%Y") | ||
|
||
if Rails.env == "test" | ||
release = Date.strptime("1/1/1970", "%d/%m/%Y") | ||
end | ||
|
||
base = [release, card.last_updated.to_date].max | ||
|
||
days_from_update = (Time.current.to_date - base).to_i | ||
|
||
days2step = {180 => 0, 180+14 => 1, 180+14*2 => 2, 180+14*3 => 3, 180+14*4 => 4} | ||
|
||
step = days2step[days_from_update] || -1 | ||
|
||
if step == -1 && days_from_update > 180 + 14*4 && (days_from_update - (180 + 14*4)) % 60 == 0 | ||
step = 4 + (days_from_update - (180 + 14*4)) / 60 | ||
end | ||
|
||
# p "step: #{step}, days_from_update: #{days_from_update}" | ||
|
||
# flag the card and notify the admin if not already done | ||
if step >= 4 && !card.disabled? | ||
card.update_attribute(:validity, :disabled) | ||
Admin::CardMailer.deactivated(card).deliver_now | ||
end | ||
|
||
# flag the card if not already done | ||
if step >= 0 && step <= 3 && !card.solicited? | ||
card.update_attribute(:validity, :solicited) | ||
end | ||
|
||
# notify the card owner | ||
if step >= 0 | ||
CardMailer.update_check(card, step).deliver_now | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.