diff --git a/Dockerfile b/Dockerfile index 5f3bed2b7..6e624d7fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,10 +9,8 @@ # FROM phusion/passenger-ruby32:2.6.1 -MAINTAINER Autolab Development Team "autolab-dev@andrew.cmu.edu" - # Change to your time zone here -RUN ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime +RUN ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime # Install dependencies ENV DEBIAN_FRONTEND=noninteractive @@ -55,11 +53,14 @@ RUN mkdir -p /home/app/webapp/log && \ chmod 0664 /home/app/webapp/log/production.log && \ chown -R app:app . -USER app +USER root +RUN chown -R app:app . + +#WORKDIR /home/app/webapp # precompile the Rails assets -ENV SECRET_KEY_BASE=dummy_secret_key_base -RUN RAILS_ENV=production bundle exec rails assets:precompile +ENV SECRET_KEY_BASE="ekz0nrn_DPG6ucv5ukw" +#RUN RAILS_ENV=production bundle exec rails assets:precompile # Clean up APT when done. USER root diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss.erb similarity index 100% rename from app/assets/stylesheets/application.scss rename to app/assets/stylesheets/application.scss.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e187c5409..35a77a46a 100755 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -5,8 +5,9 @@ class UsersController < ApplicationController skip_before_action :update_persistent_announcements before_action :set_gh_oauth_client, only: [:github_oauth, :github_oauth_callback] before_action :set_user, - only: [:github_oauth, :github_revoke, :lti_launch_initialize, - :lti_launch_link_course] + only: [:github_oauth, :github_revoke, + :show_github_update_form, :submit_github_update_form, + :lti_launch_initialize, :lti_launch_link_course] # GET /users action_auth_level :index, :student @@ -249,6 +250,22 @@ def lti_launch_link_course flash[:success] = "#{course.name} successfully linked." redirect_to(course) end + + action_auth_level :github_update, :student + def show_github_update_form + @github_integration = GithubIntegration.find_by(user_id: @user.id) + render('github_update') + end + + action_auth_level :github_update_form, :student + def submit_github_update_form + github_integration = GithubIntegration.find_by(user_id: @user.id) + + access_token = params[:access_token] + github_integration.update!(access_token:) + flash[:success] = "Updated Github Token" + redirect_to(user_path) + end action_auth_level :github_oauth, :student def github_oauth diff --git a/app/helpers/assessment_autograde_core.rb b/app/helpers/assessment_autograde_core.rb index e0f88d19b..0d8cfa903 100644 --- a/app/helpers/assessment_autograde_core.rb +++ b/app/helpers/assessment_autograde_core.rb @@ -569,4 +569,4 @@ def extend_config_module(assessment, submission, cud) raise error end -end \ No newline at end of file +end diff --git a/app/views/users/github_update.erb b/app/views/users/github_update.erb new file mode 100755 index 000000000..d98d88cf6 --- /dev/null +++ b/app/views/users/github_update.erb @@ -0,0 +1,13 @@ +<% @title = "Github Access Token" %> + +

Github Update Access Token

+<% if @github_integration %> + <%= form_with url: github_update_user_path do |form| %> +
+ <%= form.text_field :access_token, required: true %> + <%= form.label :access_token, "Access Token" %> + Helpful description here +
+ <%= form.submit "Update Token", { class: "btn primary" } %> + <% end %> +<% end %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index c9d20bf76..b7a2ab1ff 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -63,6 +63,12 @@ <% end %> <% if GithubIntegration.connected %> <% if @user.github_integration && @user.github_integration.is_connected %> + <%= link_to github_update_user_path(@user) do %> + + Update Github Token + + <% end %> + <%= link_to github_revoke_user_path(@user), data: { method: "post" } do %> Revoke Github Token diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index c7e834b7b..9bccbbcb3 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -36,6 +36,7 @@ Rails.application.config.assets.precompile += %w( eventdrops.css ) Rails.application.config.assets.precompile += %w( metricsgraphics.scss ) Rails.application.config.assets.precompile += %w( users.css.scss ) +Rails.application.config.assets.precompile += %w( bootstrap-datetimepicker.css ) Rails.application.config.assets.precompile += %w( *.js ) Rails.application.config.assets.precompile += %w( annotations.js ) @@ -68,4 +69,4 @@ Rails.application.config.assets.precompile += %w( initialize_datetimepickers.js ) Rails.application.config.assets.precompile += %w( jquery.stickytableheaders.js ) Rails.application.config.assets.precompile += %w( pdf.js ) -Rails.application.config.assets.precompile += %w( course_users.js ) \ No newline at end of file +Rails.application.config.assets.precompile += %w( course_users.js ) diff --git a/config/routes.rb b/config/routes.rb index f77d186d3..29380170a 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -79,6 +79,8 @@ get "lti_launch_initialize", on: :member post "lti_launch_link_course", on: :member post "github_revoke", on: :member + get "github_update", on: :member, to: 'users#show_github_update_form' + post 'github_update', on: :member, to: 'users#submit_github_update_form' get "github_oauth_callback", on: :collection match "update_password_for_user", on: :member, via: [:get, :put] post "change_password_for_user", on: :member