Last active
March 15, 2016 08:52
-
-
Save Samuelfaure/8e88391baf5b562ac84f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def create | |
| Compliment.create compliment_params | |
| redirect_to '/compliments/index' | |
| end |
This file contains hidden or 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
| post 'compliments/index' => 'compliments#create' | |
| post 'compliments/index' => 'compliments#add_to_cart' |
This file contains hidden or 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
| def add_to_cart | |
| @compliment_cart = Compliment.find(params[:compliment_id]) | |
| @shopping_cart.add(@compliment_cart, @compliment_cart.price) | |
| redirect_to '/compliments/index' | |
| end |
This file contains hidden or 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
| /CODE POUR ADMIN | |
| - if @user.role == "Admin" | |
| p | |
| | ==================== Espace Admin =================== | |
| p Bonjour M. l'Administrateur ! Ajouter des compliments ? | |
| /Add boostrap form | |
| div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" | |
| div class="col-lg-4 col-md-4 col-sm-4 col-xs-4" | |
| = bootstrap_form_for @compliment, url: {action: "create"} do |f| | |
| br | |
| = f.text_field :category | |
| = f.text_area :content | |
| = f.number_field :price | |
| = f.submit class: "btn btn-primary btn-lg center-block" | |
| br | |
| p | |
| | ==================== Espace Client =================== | |
| /CODE POUR CLIENT | |
| - else | |
| p Bonjour #{@user.name} | |
| h2 Les compliments suivants sont disponibles à l'achat : | |
| - @compliments.each do |compliment| | |
| br | |
| .ul class='list-group' | |
| li class="list-group-item row" | |
| .textlist class="col-lg-10 col-md-10 col-sm-10 col-xs-9" | |
| .element_compliments | |
| h4 <b>Catégorie :</b> #{compliment.category} | |
| .element_compliments | |
| h4 <b>Description :</b> #{compliment.content} | |
| .element_compliments | |
| h4 <b>Prix du compliment :</b> #{compliment.price} euros | |
| .element_compliments | |
| h4 <b>Quantite dans panier :</b> #{shopping_quantity(compliment)} | |
| = link_to raw('<i class="fa fa-cart-plus"><br><br>Ajouter</i>'), | |
| shopping_cart_path(:compliment_id => compliment.id), | |
| class: "btn btn-primary btn-right col-lg-1 col-md-1 col-sm-2 col-xs-3", | |
| method: :POST | |
| = link_to raw('<i class="fa fa-cart-plus"><br><br>Checkout</i>'), | |
| shopping_cart_path, | |
| class: "btn btn-primary btn-right col-lg-1 col-md-1 col-sm-2 col-xs-3" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment