-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Le superadmin peut paramétrer l’illustration d’une question numératie #1618
Merged
cprodhomme
merged 6 commits into
betagouv:develop
from
Captive-Studio:EVA-170-le-superadmin-peut-parametrer-lillustration-dune-question-numeratie
Aug 12, 2024
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2f54393
📝 Cadrage
2598c7c
✨ Ajoute une illustration dans le model Question
e81c6df
✨ Permet de resizer une illustration
6ec10ec
✨ Permet d'ajouter une illustration depuis le formulaire de creation …
a446911
✨ Permet de visualiser l'image depuis un lien dans le show de la ques…
80c9ada
♻️ Supprime la duplication en passant les formats autorisés dans une …
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
https://github.com/Scalingo/apt-buildpack.git | ||
https://github.com/Scalingo/ffmpeg-buildpack.git | ||
https://github.com/Scalingo/ruby-buildpack.git | ||
https://github.com/Scalingo/ruby-buildpack.git |
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,2 @@ | ||
# Pour la manipulation d'image | ||
libvips-dev |
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
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
56 changes: 56 additions & 0 deletions
56
...0-le-superadmin-peut-parametrer-lillustration-dune-question-numeratie/readme.md
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,56 @@ | ||
<!-- 📄 Standard : https://www.notion.so/captive/Le-cadrage-technique-dbb611e45f114737a6b14745caa584e9?pvs=4 --> | ||
# Le superadmin peut paramétrer l’illustration d’une question numératie | ||
|
||
[Lien du ticket](https://captive-team.atlassian.net/browse/EVA-170?atlOrigin=eyJpIjoiODVkNzRlZjE3ZmU1NDNlMjkwZTVkN2IzYmYwNzE3ZjkiLCJwIjoiaiJ9) | ||
|
||
|
||
## 1 - Ajout d'un nouveau champs. | ||
|
||
Ajouter dans le model `Question` : `has_one_attached :image` | ||
|
||
## 2 - Ajouter une validation sur le type de fichier coté back | ||
|
||
On souhaite authoriser uniquement les fichier JPG, PNG et WebP. Donc ajouter dans le model `Question` | ||
|
||
```ruby | ||
validates :image, | ||
blob: { content_type: ["image/png", "image/jpeg", "image/webp"] } | ||
``` | ||
|
||
## 3 - Redimensionner l'image | ||
|
||
Il va falloir redimensionner les images `1008x566` | ||
Pour ce faire il y a plusieurs etapes : | ||
|
||
- Ajouter la gem image_processing | ||
- Dans le .buildpack ajouter `https://github.com/Scalingo/apt-buildpack.git` | ||
- Creer un fichier Aptfile dans lequel on ajoutera `libvips-dev` | ||
|
||
Modifier le model : | ||
|
||
```ruby | ||
has_one_attached :photo do |attachable| | ||
attachable.variant :thumb, | ||
resize_to_limit: [1008, 566], | ||
preprocessed: true | ||
end | ||
``` | ||
|
||
## 4 - Ajouter le champs dans le formulaire | ||
|
||
Dans le formulaire `question_qcms/_form.html.arb` ajouter: | ||
|
||
`f.input :image, as: :file, input_html: { accept: 'image/png,image/jpg,image/jpeg' }` | ||
|
||
Ne pas oublier de le preciser dans les permit_params | ||
|
||
Ajouter egalement un hint sur ce champs : | ||
`La taille de l’image rendu est 1008x566` | ||
|
||
## 5 - Ajouter la traduction du champs. | ||
|
||
Ceci se passe dans le fichier `question_qcms.yml` en ajoutant la traduction suivante : `Image du jeu` | ||
|
||
## 6 - Niveau des droits | ||
|
||
Seul le super admin peut ajouter une image. Les droits pour ajouter des questions sont deja destiné uniquement aux superadmin. Donc rien a faire de ce coté. |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu n'accepte pas le webp ici, c'est normal ?
Tu duplique d'ailleurs du texte du model Question.
J'aurais tendance dans le model Question à faire :