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
Make buttons work #13473
Merged
Merged
Make buttons work #13473
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
aaf27e1
Checkpoint
mehalshah 60a813f
Some buttons work for CSF
mehalshah 009b601
Make buttons on the landing page actually go places
mehalshah a4bcd43
Require an enrollment code when generating the certificate
mehalshah 0c09317
Pass print certificate URL to the button
mehalshah 3cb138b
Certificate controller tests
mehalshah 9cfe64e
Use scopes
mehalshah File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
15 changes: 15 additions & 0 deletions
15
dashboard/app/controllers/pd/csf_certificate_controller.rb
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,15 @@ | ||
class Pd::CsfCertificateController < ApplicationController | ||
before_action :authenticate_user! | ||
load_resource :enrollment, class: 'Pd::Enrollment', find_by: :code, id_param: :enrollment_code | ||
|
||
def generate_certificate | ||
image = create_certificate_image2( | ||
dashboard_dir('app', 'assets', 'images', 'pd_workshop_certificate_csf.png'), | ||
@enrollment.try(:full_name) || '', | ||
y: 444, | ||
height: 100 | ||
) | ||
|
||
send_data image.to_blob, type: 'image/png', disposition: 'inline' | ||
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
27 changes: 27 additions & 0 deletions
27
dashboard/test/controllers/pd/csf_certificate_controller_test.rb
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,27 @@ | ||
require 'test_helper' | ||
|
||
class Pd::CsfCertificateControllerTest < ::ActionController::TestCase | ||
setup do | ||
@user = create :teacher | ||
sign_in(@user) | ||
@enrollment = create :pd_enrollment | ||
end | ||
|
||
test 'Generates certificate for a real user' do | ||
get :generate_certificate, params: {enrollment_code: @enrollment.code} | ||
assert_response :success | ||
end | ||
|
||
test 'Generates no certificate for an invalid enrollment' do | ||
assert_raise ActiveRecord::RecordNotFound do | ||
get :generate_certificate, params: {enrollment_code: "garbage code"} | ||
end | ||
end | ||
|
||
test 'Redirects if user is signed out' do | ||
sign_out(@user) | ||
|
||
get :generate_certificate, params: {enrollment_code: @enrollment.code} | ||
assert_response :redirect | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just realized, after seeing these tests, that any enrollment code will work on this url, not just those for ended workshops. Not necessary in this PR, but we might want to add some more validation. |
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.
please add some basic tests for this controller: