From 01026b85706dfe968bd803b3706e112e8309f67c Mon Sep 17 00:00:00 2001 From: Denis Lukyanov Date: Sat, 6 Dec 2014 18:29:17 +0300 Subject: [PATCH] add validations and faq --- Gemfile | 1 + Gemfile.lock | 2 ++ app/controllers/welcome_controller.rb | 4 ++++ app/models/license_agreement.rb | 2 ++ app/models/license_agreement_term.rb | 2 ++ app/models/question.rb | 2 ++ app/models/visitor.rb | 2 ++ app/views/devise/registrations/edit.html.erb | 8 ++++---- app/views/devise/registrations/new.html.erb | 8 ++++---- app/views/shared/_navigation.html.slim | 2 +- app/views/welcome/faq.html.slim | 12 ++++++++++++ config/routes.rb | 1 + db/migrate/20141206151753_create_questions.rb | 10 ++++++++++ db/schema.rb | 9 ++++++++- ddagent-install.log | 15 +++++++++++++++ 15 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 app/models/question.rb create mode 100644 app/views/welcome/faq.html.slim create mode 100644 db/migrate/20141206151753_create_questions.rb create mode 100644 ddagent-install.log diff --git a/Gemfile b/Gemfile index 651c8d9..fe81361 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,7 @@ gem 'omniauth-facebook' gem 'bootstrap-sass' gem 'medium-editor-rails' gem "cocoon" +gem "dogstatsd-ruby" # Use mysql as the database for Active Record gem 'mysql2' diff --git a/Gemfile.lock b/Gemfile.lock index 95e81fb..28acaba 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,6 +50,7 @@ GEM thread_safe (~> 0.1) warden (~> 1.2.3) dimensions (1.3.0) + dogstatsd-ruby (1.4.1) erubis (2.7.0) execjs (2.2.2) faraday (0.9.0) @@ -176,6 +177,7 @@ DEPENDENCIES cocoon coffee-rails (~> 4.0.0) devise + dogstatsd-ruby jbuilder (~> 2.0) jquery-rails medium-editor-rails diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index f9b859b..9357bfb 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -1,4 +1,8 @@ class WelcomeController < ApplicationController def index end + + def faq + @questions = Question.all + end end diff --git a/app/models/license_agreement.rb b/app/models/license_agreement.rb index f441268..b5fc5a4 100644 --- a/app/models/license_agreement.rb +++ b/app/models/license_agreement.rb @@ -2,4 +2,6 @@ class LicenseAgreement < ActiveRecord::Base belongs_to :user has_many :license_agreement_terms accepts_nested_attributes_for :license_agreement_terms + + validates :name, :domain, :user_id, presence: true end diff --git a/app/models/license_agreement_term.rb b/app/models/license_agreement_term.rb index 47edaac..1b1a224 100644 --- a/app/models/license_agreement_term.rb +++ b/app/models/license_agreement_term.rb @@ -1,4 +1,6 @@ class LicenseAgreementTerm < ActiveRecord::Base has_many :term_acceptances belongs_to :license_agreement + + validates :text, :license_agreement_id, :code, presence: true end diff --git a/app/models/question.rb b/app/models/question.rb new file mode 100644 index 0000000..0ba7683 --- /dev/null +++ b/app/models/question.rb @@ -0,0 +1,2 @@ +class Question < ActiveRecord::Base +end diff --git a/app/models/visitor.rb b/app/models/visitor.rb index e42622b..72f9730 100644 --- a/app/models/visitor.rb +++ b/app/models/visitor.rb @@ -1,3 +1,5 @@ class Visitor < ActiveRecord::Base has_many :term_acceptances + + validates :uid, presence: true end diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 8041360..ee4c46e 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -4,13 +4,13 @@ <%= devise_error_messages! %>
- <%= f.label :name %>
- <%= f.text_field :name, autofocus: true, class: "form-control" %> + <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, class: "form-control" %>
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, class: "form-control" %> + <%= f.label :name %>
+ <%= f.text_field :name, autofocus: true, class: "form-control" %>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 32362f6..70fbe72 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -4,13 +4,13 @@ <%= devise_error_messages! %>
- <%= f.label :name %>
- <%= f.text_field :name, autofocus: true, class: "form-control" %> + <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, class: "form-control" %>
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, class: "form-control" %> + <%= f.label :name %>
+ <%= f.text_field :name, autofocus: true, class: "form-control" %>
diff --git a/app/views/shared/_navigation.html.slim b/app/views/shared/_navigation.html.slim index 262b001..ef74158 100644 --- a/app/views/shared/_navigation.html.slim +++ b/app/views/shared/_navigation.html.slim @@ -12,7 +12,7 @@ nav.navbar.navbar-default role="navigation" #bs-example-navbar-collapse-1.collapse.navbar-collapse ul.nav.navbar-nav li.active - a href="#" FAQ + = link_to "FAQ", faq_path li a href="#" Documentation ul.nav.navbar-nav.navbar-right diff --git a/app/views/welcome/faq.html.slim b/app/views/welcome/faq.html.slim new file mode 100644 index 0000000..a8499d6 --- /dev/null +++ b/app/views/welcome/faq.html.slim @@ -0,0 +1,12 @@ +h3 Frequently asked questions +#accordion.panel-group + - @questions.each_with_index do |question, i| + .panel.panel-default + .panel-heading + h4.panel-title + a data-parent="#accordion" data-toggle="collapse" href="#collapse-#{question.id}" + - i += 1 + = "#{i}. #{question.question}" + .panel-collapse.collapse id="collapse-#{question.id}" + .panel-body + = raw question.answer diff --git a/config/routes.rb b/config/routes.rb index d67394b..e101f3e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,7 @@ devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks", :registrations => "registrations", } root 'welcome#index' + get '/faq' => 'welcome#faq' get '/demo' => 'markup#demo' resources :license_agreements # The priority is based upon order of creation: first created -> highest priority. diff --git a/db/migrate/20141206151753_create_questions.rb b/db/migrate/20141206151753_create_questions.rb new file mode 100644 index 0000000..4a3f7dc --- /dev/null +++ b/db/migrate/20141206151753_create_questions.rb @@ -0,0 +1,10 @@ +class CreateQuestions < ActiveRecord::Migration + def change + create_table :questions do |t| + t.string :question + t.text :answer + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 59d035e..9b2916d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20141206095114) do +ActiveRecord::Schema.define(version: 20141206151753) do create_table "license_agreement_terms", force: true do |t| t.string "code" @@ -34,6 +34,13 @@ add_index "license_agreements", ["user_id"], name: "index_license_agreements_on_user_id", using: :btree + create_table "questions", force: true do |t| + t.string "question" + t.text "answer" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "term_acceptances", force: true do |t| t.integer "visitor_id" t.integer "license_agreement_term_id" diff --git a/ddagent-install.log b/ddagent-install.log new file mode 100644 index 0000000..dc2e1af --- /dev/null +++ b/ddagent-install.log @@ -0,0 +1,15 @@ + +* Installing APT package sources for Datadog + +sh: 1: cannot create /etc/apt/sources.list.d/datadog.list: Directory nonexistent + +It looks like you hit an issue when trying to install the Agent. + +Troubleshooting and basic usage information for the Agent are available at: + + http://docs.datadoghq.com/guides/basic_agent_usage/ + +If you're still having problems, please send an email to support@datadoghq.com +with the contents of ddagent-install.log and we'll do our very best to help you +solve your problem. +