From 76bf3dd3f0ef18973f37e9da3ec9f45cc1c76c3a Mon Sep 17 00:00:00 2001 From: "leo.selig" Date: Thu, 4 Feb 2016 10:59:49 +0100 Subject: [PATCH] Scaffold CodeHarbourLink with field oauth2token (leoselig/codeocean#2) --- .../javascripts/code_harbor_links.js.coffee | 3 + .../stylesheets/code_harbor_links.css.scss | 3 + app/assets/stylesheets/scaffolds.css.scss | 69 +++++++++++++++++ .../code_harbor_links_controller.rb | 74 +++++++++++++++++++ app/helpers/code_harbor_links_helper.rb | 2 + app/models/code_harbor_link.rb | 2 + app/views/code_harbor_links/_form.html.erb | 21 ++++++ app/views/code_harbor_links/edit.html.erb | 6 ++ app/views/code_harbor_links/index.html.erb | 25 +++++++ .../code_harbor_links/index.json.jbuilder | 4 + app/views/code_harbor_links/new.html.erb | 5 ++ app/views/code_harbor_links/show.html.erb | 9 +++ .../code_harbor_links/show.json.jbuilder | 1 + config/routes.rb | 1 + ...20160204094409_create_code_harbor_links.rb | 9 +++ 15 files changed, 234 insertions(+) create mode 100644 app/assets/javascripts/code_harbor_links.js.coffee create mode 100644 app/assets/stylesheets/code_harbor_links.css.scss create mode 100644 app/assets/stylesheets/scaffolds.css.scss create mode 100644 app/controllers/code_harbor_links_controller.rb create mode 100644 app/helpers/code_harbor_links_helper.rb create mode 100644 app/models/code_harbor_link.rb create mode 100644 app/views/code_harbor_links/_form.html.erb create mode 100644 app/views/code_harbor_links/edit.html.erb create mode 100644 app/views/code_harbor_links/index.html.erb create mode 100644 app/views/code_harbor_links/index.json.jbuilder create mode 100644 app/views/code_harbor_links/new.html.erb create mode 100644 app/views/code_harbor_links/show.html.erb create mode 100644 app/views/code_harbor_links/show.json.jbuilder create mode 100644 db/migrate/20160204094409_create_code_harbor_links.rb diff --git a/app/assets/javascripts/code_harbor_links.js.coffee b/app/assets/javascripts/code_harbor_links.js.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/code_harbor_links.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/code_harbor_links.css.scss b/app/assets/stylesheets/code_harbor_links.css.scss new file mode 100644 index 00000000..5ca7b3ce --- /dev/null +++ b/app/assets/stylesheets/code_harbor_links.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the CodeHarborLinks controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss new file mode 100644 index 00000000..6ec6a8ff --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -0,0 +1,69 @@ +body { + background-color: #fff; + color: #333; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + &:visited { + color: #666; + } + &:hover { + color: #fff; + background-color: #000; + } +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; + } + ul li { + font-size: 12px; + list-style: square; + } +} diff --git a/app/controllers/code_harbor_links_controller.rb b/app/controllers/code_harbor_links_controller.rb new file mode 100644 index 00000000..849af648 --- /dev/null +++ b/app/controllers/code_harbor_links_controller.rb @@ -0,0 +1,74 @@ +class CodeHarborLinksController < ApplicationController + before_action :set_code_harbor_link, only: [:show, :edit, :update, :destroy] + + # GET /code_harbor_links + # GET /code_harbor_links.json + def index + @code_harbor_links = CodeHarborLink.all + end + + # GET /code_harbor_links/1 + # GET /code_harbor_links/1.json + def show + end + + # GET /code_harbor_links/new + def new + @code_harbor_link = CodeHarborLink.new + end + + # GET /code_harbor_links/1/edit + def edit + end + + # POST /code_harbor_links + # POST /code_harbor_links.json + def create + @code_harbor_link = CodeHarborLink.new(code_harbor_link_params) + + respond_to do |format| + if @code_harbor_link.save + format.html { redirect_to @code_harbor_link, notice: 'Code harbor link was successfully created.' } + format.json { render :show, status: :created, location: @code_harbor_link } + else + format.html { render :new } + format.json { render json: @code_harbor_link.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /code_harbor_links/1 + # PATCH/PUT /code_harbor_links/1.json + def update + respond_to do |format| + if @code_harbor_link.update(code_harbor_link_params) + format.html { redirect_to @code_harbor_link, notice: 'Code harbor link was successfully updated.' } + format.json { render :show, status: :ok, location: @code_harbor_link } + else + format.html { render :edit } + format.json { render json: @code_harbor_link.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /code_harbor_links/1 + # DELETE /code_harbor_links/1.json + def destroy + @code_harbor_link.destroy + respond_to do |format| + format.html { redirect_to code_harbor_links_url, notice: 'Code harbor link was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_code_harbor_link + @code_harbor_link = CodeHarborLink.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def code_harbor_link_params + params.require(:code_harbor_link).permit(:oauth2token) + end +end diff --git a/app/helpers/code_harbor_links_helper.rb b/app/helpers/code_harbor_links_helper.rb new file mode 100644 index 00000000..d8e92ddf --- /dev/null +++ b/app/helpers/code_harbor_links_helper.rb @@ -0,0 +1,2 @@ +module CodeHarborLinksHelper +end diff --git a/app/models/code_harbor_link.rb b/app/models/code_harbor_link.rb new file mode 100644 index 00000000..d5012e11 --- /dev/null +++ b/app/models/code_harbor_link.rb @@ -0,0 +1,2 @@ +class CodeHarborLink < ActiveRecord::Base +end diff --git a/app/views/code_harbor_links/_form.html.erb b/app/views/code_harbor_links/_form.html.erb new file mode 100644 index 00000000..b4c5b2ab --- /dev/null +++ b/app/views/code_harbor_links/_form.html.erb @@ -0,0 +1,21 @@ +<%= form_for(@code_harbor_link) do |f| %> + <% if @code_harbor_link.errors.any? %> +
+

<%= pluralize(@code_harbor_link.errors.count, "error") %> prohibited this code_harbor_link from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :oauth2token %>
+ <%= f.text_field :oauth2token %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/code_harbor_links/edit.html.erb b/app/views/code_harbor_links/edit.html.erb new file mode 100644 index 00000000..f75f360d --- /dev/null +++ b/app/views/code_harbor_links/edit.html.erb @@ -0,0 +1,6 @@ +

Editing code_harbor_link

+ +<%= render 'form' %> + +<%= link_to 'Show', @code_harbor_link %> | +<%= link_to 'Back', code_harbor_links_path %> diff --git a/app/views/code_harbor_links/index.html.erb b/app/views/code_harbor_links/index.html.erb new file mode 100644 index 00000000..0069df36 --- /dev/null +++ b/app/views/code_harbor_links/index.html.erb @@ -0,0 +1,25 @@ +

Listing code_harbor_links

+ + + + + + + + + + + <% @code_harbor_links.each do |code_harbor_link| %> + + + + + + + <% end %> + +
Oauth2token
<%= code_harbor_link.oauth2token %><%= link_to 'Show', code_harbor_link %><%= link_to 'Edit', edit_code_harbor_link_path(code_harbor_link) %><%= link_to 'Destroy', code_harbor_link, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Code harbor link', new_code_harbor_link_path %> diff --git a/app/views/code_harbor_links/index.json.jbuilder b/app/views/code_harbor_links/index.json.jbuilder new file mode 100644 index 00000000..defff8f3 --- /dev/null +++ b/app/views/code_harbor_links/index.json.jbuilder @@ -0,0 +1,4 @@ +json.array!(@code_harbor_links) do |code_harbor_link| + json.extract! code_harbor_link, :id, :oauth2token + json.url code_harbor_link_url(code_harbor_link, format: :json) +end diff --git a/app/views/code_harbor_links/new.html.erb b/app/views/code_harbor_links/new.html.erb new file mode 100644 index 00000000..0ba6ae61 --- /dev/null +++ b/app/views/code_harbor_links/new.html.erb @@ -0,0 +1,5 @@ +

New code_harbor_link

+ +<%= render 'form' %> + +<%= link_to 'Back', code_harbor_links_path %> diff --git a/app/views/code_harbor_links/show.html.erb b/app/views/code_harbor_links/show.html.erb new file mode 100644 index 00000000..4bad1a5e --- /dev/null +++ b/app/views/code_harbor_links/show.html.erb @@ -0,0 +1,9 @@ +

<%= notice %>

+ +

+ Oauth2token: + <%= @code_harbor_link.oauth2token %> +

+ +<%= link_to 'Edit', edit_code_harbor_link_path(@code_harbor_link) %> | +<%= link_to 'Back', code_harbor_links_path %> diff --git a/app/views/code_harbor_links/show.json.jbuilder b/app/views/code_harbor_links/show.json.jbuilder new file mode 100644 index 00000000..b8a1e789 --- /dev/null +++ b/app/views/code_harbor_links/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @code_harbor_link, :id, :oauth2token, :created_at, :updated_at diff --git a/config/routes.rb b/config/routes.rb index 24f6a0d9..4b9c5dc2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,7 @@ FILENAME_REGEXP = /[\w\.]+/ unless Kernel.const_defined?(:FILENAME_REGEXP) Rails.application.routes.draw do + resources :code_harbor_links resources :request_for_comments get '/my_request_for_comments', as: 'my_request_for_comments', to: 'request_for_comments#get_my_comment_requests' resources :comments, except: [:destroy] do diff --git a/db/migrate/20160204094409_create_code_harbor_links.rb b/db/migrate/20160204094409_create_code_harbor_links.rb new file mode 100644 index 00000000..b87d5c9d --- /dev/null +++ b/db/migrate/20160204094409_create_code_harbor_links.rb @@ -0,0 +1,9 @@ +class CreateCodeHarborLinks < ActiveRecord::Migration + def change + create_table :code_harbor_links do |t| + t.string :oauth2token + + t.timestamps + end + end +end