-
Notifications
You must be signed in to change notification settings - Fork 650
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
Add admin view to copy courses from production instance of dashboard (#5528) #5528
Add admin view to copy courses from production instance of dashboard (#5528) #5528
Conversation
…update_logs keys as integers instead of strings
@@ -14,21 +14,23 @@ | |||
%h2 Useful links |
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.
I ordered the links alphabetically
setup/copy_course_from_production.rb
Outdated
# When parsing update_logs from flags, keys are set as strings instead of integers | ||
# This causes problems, so we need to force the keys to be integers. | ||
def fix_update_logs_parsing(update_logs) | ||
update_logs.transform_keys(&:to_i) | ||
end |
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.
There is a lot of code duplication, do we want to keep this command?
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.
No, this file should be removed.
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.
Done on fff45d6
@ragesoss this PR is ready for review whenever you have some free time. Failing tests don't seem to be related to the PR changes. |
app/services/copy_course.rb
Outdated
@home_wiki = Wiki.get_or_create(language: @course_data['home_wiki']['language'], | ||
project: @course_data['home_wiki']['project']) | ||
copied_data['home_wiki_id'] = @home_wiki.id | ||
copied_data['passcode'] = 'passcode' # set an arbitrary passcode |
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.
Since we could potential use this in production to copy from one server to another, I think it will be better to use a random passcode via GeneratePasscode.call
.
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.
Done on 65188da
app/views/admin/index.html.haml
Outdated
%li | ||
%a{href: '/sidekiq'} Job queue | ||
%a{href: '/copy_course'} Copy Course from Another Dashboard Server |
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.
'Copy course from another server'. No need for extra capitalization, and I think 'Dashboard' is redundant.
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.
Done on 048de68
@@ -1,5 +1,5 @@ | |||
- if flash[:notice] | |||
.notification= flash[:notice] | |||
.notification= flash[:notice].html_safe |
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.
What is this change for?
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.
oh I cherry-picked this from the previous PR.
We are using flash[:notice]
for rendering the success message in the controller, and that message has a link to the new course (which is added using <a>
tag). It looks like we need to add the html_safe
to indicate that the string should be considered safe HTML content and should not be escaped when rendered in a view. Without the html_safe
, the link doesn't render properly.
This looks great overall. |
What this PR does
This PR creates a new admin view to dump course data from a production dashboard to the local environment.
In order to do this a new copy course service was created, based on the already existing
setup/copy_course_from_production.rb
command.The PR also fixes an existing bug on the command related to
update_logs
keys being parsed as string instead of integers.Closes #4911
Screenshots
Before:
No admin view
After:
Example of success and failure:
example.webm
Open questions and concerns
There are a lot of duplicated code in
setup/copy_course_from_production.rb
and the new copy course service. We should either delete the command or make a refactor on it to use the sevice.It also looks like there is some code duplication in
setup/populate_dashboard.rb
that we may want to refactor.