-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Create a new promotion code inside an existing promotion #2872
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dbce7dc
Sort promotion codes
stem 044ff82
Rename the spec
stem 400c88e
Add a link to the promotion's code list
stem 31c4072
Add a form to create promotion code
stem 30db0da
Setup PromotionCode management ACL
stem b8f02db
Fix indentation
stem 8bd16f7
Use `errors.full_messages.to_sentence`
stem e3866a2
Reword translations
stem e549cd7
Use `.build` instead of `.new` on promotion_codes
stem 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
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
31 changes: 31 additions & 0 deletions
31
backend/app/views/spree/admin/promotion_codes/new.html.erb
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,31 @@ | ||
<% admin_breadcrumb link_to plural_resource_name(Spree::Promotion), spree.admin_promotions_path %> | ||
<% admin_breadcrumb link_to(@promotion.name, spree.edit_admin_promotion_path(@promotion)) %> | ||
<% admin_breadcrumb plural_resource_name(Spree::PromotionCode) %> | ||
|
||
<% content_for :page_actions do %> | ||
<li> | ||
<%= link_to t('spree.view_promotion_codes_list'), admin_promotion_promotion_codes_path(promotion_id: @promotion.id), class: 'btn btn-primary' %> | ||
|
||
<%= link_to t('spree.download_promotion_codes_list'), admin_promotion_promotion_codes_path(promotion_id: @promotion.id, format: :csv), class: 'btn btn-primary' %> | ||
</li> | ||
<% end %> | ||
|
||
<%= form_for [:admin, @promotion, @promotion_code], method: :post do |f| %> | ||
<fieldset class="no-border-top"> | ||
<%= render partial: 'spree/shared/error_messages', locals: { target: @promotion_code } %> | ||
|
||
<div class="row"> | ||
<div class="col-4"> | ||
<%= f.field_container :value do %> | ||
<%= f.label :value, class: 'required' %> | ||
<%= f.text_field :value, class: 'fullwidth', required: true %> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<div class="form-buttons filter-actions actions" data-hook="buttons"> | ||
<%= button_tag t('spree.actions.create'), class: 'btn btn-primary' %> | ||
<%= link_to t('spree.actions.cancel'), admin_promotion_promotion_codes_url(@promotion), class: 'button' %> | ||
</div> | ||
</fieldset> | ||
<% 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
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
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.
just wondering why we are not using ActiveRecord
build
here. Is there a specific reason? I think you can even do@promotion.build_promotion_code
right?Same in the create method where it's not a conventional create. I'm taking a look at scaffolded rails controller templates.
Let me know!
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.
@promotion.build_promotion_code
does not seems to exists :And
new
orbuild
return the same object :I've switched to
build