Skip to content

[WIP] Create grid layout to list all CoderDojo #9

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

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,3 @@ ooをできるようにする / oo機能をリファクタリングする / oo
- [ ] ooの機能を実装
- [ ] ooのリファクタリング

ちなみにTASKリストの書き方はこんな感じ

```
- [ ] ooのテストを実装
- [ ] ooの機能を実装
- [ ] ooのリファクタリング
```
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
# Ignore bundler config & bundler gems
/.bundle
vendor/bundle

# Ignore the default SQLite database.
/db/*.sqlite3
Expand Down
1 change: 1 addition & 0 deletions .rbenv-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.3.1
11 changes: 11 additions & 0 deletions app/models/coder_dojo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CoderDojo < ActiveRecord::Base
validates :name, presence: true, length: { maximum: 50 }
validates :course, presence: true, length: { maximum: 25 }
validates :caption, presence: true, length: { maximum: 60 }
validates :venue, presence: true
validates :region, presence: true
validates :logo_image_url, presence: true
validates :redirect_url, presence: true
validates :user_name, presence: true, length: { maximum: 50 }
validates :email, presence: true, length: { maximum: 255 }
end
6 changes: 6 additions & 0 deletions app/models/coder_dojo_list_widget.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class CoderDojoListWidget < Widget
Copy link
Member Author

@nanophate nanophate Nov 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scrivitoに直接データを取っているので、自分のdbにアクセスして取得できるようにしたい。

attribute :image, :reference
attribute :headline, :html
attribute :tag, :string
attribute :caption, :string
end
2 changes: 1 addition & 1 deletion app/models/footer_widget.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class FooterWidget < Widget
attribute :headline, :html
attribute :paragraph, :html
attribute :line, :html
end
4 changes: 4 additions & 0 deletions app/views/coder_dojo_list_widget/details.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%= scrivito_medium_dialog do %>
<%= scrivito_details_for CoderDojoListWidget.description_for_editor do %>
<% end %>
<% end %>
8 changes: 8 additions & 0 deletions app/views/coder_dojo_list_widget/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="row">
<div class="col-1">
<%= scrivito_image_tag widget, :image, class:'image-responsive center-block clearfix'%>
<%= scrivito_tag :h1, widget, :headline, data: {newlines: false} %>
<%= scrivito_tag :p, widget, :tag, class:'cover-text-white'%>
<%= scrivito_tag :p, widget, :caption, class:'cover-text-white'%>
</div>
</div>
1 change: 1 addition & 0 deletions app/views/coder_dojo_list_widget/thumbnail.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= scrivito_thumbnail CoderDojoListWidget.description_for_editor %>
2 changes: 1 addition & 1 deletion app/views/footer_widget/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="col-12">
<div class="col-3 cover-bg-blue">
<%= scrivito_tag :h5, widget, :headline, class:'cover-text-white', style:'padding-top:20px;' %>
<%= scrivito_tag :p, widget, :paragraph, class:'cover-text-white', style:'padding-bottom:60; padding-top:20px;' %>
<%= scrivito_tag :div, widget, :line, class:'cover-text-white', style:'padding-bottom:60; padding-top:20px;' %>
</div>
</div>

1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@
scrivito_route '/', using: 'homepage'
scrivito_route '(/)(*slug-):id', using: 'slug_id'
scrivito_route '/*permalink', using: 'permalink', format: false

end
17 changes: 17 additions & 0 deletions db/migrate/20160606065215_create_coder_dojos.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class CreateCoderDojos < ActiveRecord::Migration
def change
create_table :coder_dojos do |t|
t.string :name
t.string :course
t.string :caption
t.string :venue
t.integer :region
t.string :logo_image_url
t.string :redirect_url
t.string :user_name
t.string :email

t.timestamps null: false
end
end
end
30 changes: 30 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160606065215) do

create_table "coder_dojos", force: :cascade do |t|
t.string "name"
t.string "course"
t.string "caption"
t.string "venue"
t.integer "region"
t.string "logo_image_url"
t.string "redirect_url"
t.string "user_name"
t.string "email"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

end
23 changes: 23 additions & 0 deletions test/fixtures/coder_dojos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
name: MyString
course: MyString
caption: MyString
venue: MyString
region: 1
logo_image_url: MyString
redirect_url: MyString
user_name: MyString
email: MyString

two:
name: MyString
course: MyString
caption: MyString
venue: MyString
region: 1
logo_image_url: MyString
redirect_url: MyString
user_name: MyString
email: MyString
65 changes: 65 additions & 0 deletions test/models/coder_dojo_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
require 'test_helper'

class CoderDojoTest < ActiveSupport::TestCase
def setup
@dojo = CoderDojo.new(name: "Example User",
course: "scratch",
caption: "Weekly Event",
venue: "okinawa",
region: '47',
logo_image_url: "https://www.example.com/logo.png",
redirect_url: "https://www.facebook.com",
user_name: "example",
email: "user@example.com")
end

test "should be valid" do
assert @dojo.valid?
end

test "name should be present" do
@dojo.name = "c" * 51
assert_not @dojo.valid?
end

test "course should be present" do
@dojo.course = "c" * 244 + "@example.com"
assert_not @dojo.valid?
end

test "caption should be present" do
@dojo.caption = "c " * 60
assert_not @dojo.valid?
end

test "venue should be present" do
@dojo.venue = " "
assert_not @dojo.valid?
end

test "region should be present" do
@dojo.region = ' '
assert_not @dojo.valid?
end

test "logo should be present" do
@dojo.logo_image_url = " "
assert_not @dojo.valid?
end

test "dojo url should be present" do
@dojo.redirect_url = " "
assert_not @dojo.valid?
end

test "user name should be present" do
@dojo.user_name = "c" * 51
assert_not @dojo.valid?
end

test "user email should be present" do
@dojo.email = "c" * 244 + "@example.com"
assert_not @dojo.valid?
end

end