diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 4a67b4eb08cd76ebb73800a90723ca44edd74fcc..608172a8ce87f463e76c3ad98f01d9fb013897e7 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -16,4 +16,4 @@ //= require jquery.turbolinks //= require bootstrap-sprockets //= require select2 -//= require_tree ./application +//= require_tree ./application \ No newline at end of file diff --git a/app/assets/javascripts/management/carousel.coffee b/app/assets/javascripts/management/carousel.coffee new file mode 100644 index 0000000000000000000000000000000000000000..24f83d18bbd38c24c4f7c3c2fc360cd68e857a2a --- /dev/null +++ b/app/assets/javascripts/management/carousel.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/application/welcome.scss b/app/assets/stylesheets/application/welcome.scss index 293aecd53359ddd05db69e7f4d3dd9978247120a..57c821daaf2a5ba7402e7a832c67c36bb5fecb4d 100644 --- a/app/assets/stylesheets/application/welcome.scss +++ b/app/assets/stylesheets/application/welcome.scss @@ -15,7 +15,6 @@ $carousel_size: 400px; .carousel { height: $carousel_size; - margin-bottom: 60px; h1{ background-color: rgba(37, 68, 32, 0.75); } @@ -27,6 +26,9 @@ $carousel_size: 400px; .carousel h1 { background-color: rgba(0, 0, 0, 0.75); } +.carousel ol { + background-color: rgba(0, 0, 0, 0.10); +} .carousel-caption { z-index: 10; @@ -41,7 +43,8 @@ $carousel_size: 400px; top: 0; left: 0; min-width: 100%; - height: $carousel_size; + height: 400px !important; + } .carousel-indicators li { diff --git a/app/assets/stylesheets/management/carousel.scss b/app/assets/stylesheets/management/carousel.scss new file mode 100644 index 0000000000000000000000000000000000000000..89da7e1046eebfd411c84d8414cc3ac48ec4ea90 --- /dev/null +++ b/app/assets/stylesheets/management/carousel.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the management/carousel controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/management/carousels_controller.rb b/app/controllers/management/carousels_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..80297e14ce91fc55784b6ae4f9d4b528d708d07d --- /dev/null +++ b/app/controllers/management/carousels_controller.rb @@ -0,0 +1,59 @@ +class Management::CarouselsController < ManagementController + before_action :set_carousel, only: [ :edit, :update, :destroy] + + def index + @carousels = carousel_repository.all + end + + def new + @carousel = Carousel.new + end + + def create + @carousel = Carousel.new(carousel_params) + + respond_to do |format| + if @carousel.save + format.html { redirect_to management_carousels_path} + else + format.html { render :new } + end + end + end + + def edit + end + + def update + respond_to do |format| + if carousel_repository.update(@carousel, carousel_params) + format.html { redirect_to management_carousels_path} + else + format.html { render :edit } + end + end + end + + def destroy + @carousel.image = nil + carousel_repository.destroy @carousel + respond_to do |format| + format.html { redirect_to management_carousels_path} + end + end + + private + + def carousel_repository + repository.for :carousel + end + + def set_carousel + @carousel = carousel_repository.find params[:id] + end + + def carousel_params + params.require(:carousel).permit(:title, :url, :image) + end + +end diff --git a/app/controllers/management/highlights_controller.rb b/app/controllers/management/highlights_controller.rb deleted file mode 100644 index fcfbba8b2aa52afc6ffd227e386ff9b52cc2ecee..0000000000000000000000000000000000000000 --- a/app/controllers/management/highlights_controller.rb +++ /dev/null @@ -1,40 +0,0 @@ -class Management::HighlightsController < ManagementController - - def index - @highlights = highlight_repository.all - end - - def show - end - - def new - end - - def delete - @highlights = highlight_repository.all - end - - def create - - highlight_repository.insert_data(params[:name],params[:url]) - redirect_to management_highlights_index_path - - end - - def destroy - - params[:id].each do |id| - highlight_repository.destroy_data(id) - end - redirect_to management_highlights_index_path - - end - - private - - def highlight_repository - repository.for :highlight - end - - -end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 109608f4f9f3840c2d2ad4bd9a38e3b613dc8001..3de11c0925264182b8df6e435aa94f5b243e572f 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -5,24 +5,15 @@ class WelcomeController < ApplicationController @General = Array.new mainPage = repository.for(:mainPage).all.first - @Carousel = mainPage["carousel"].collect do |id| - repository.for(:webLink).find(id)[0] #orientdb returns a hash inside an array, I want only the hash - end + @Carousel = carousel_repository.all @General = mainPage["highlights"].collect do |id| repository.for(:learning_object).find(id) end - @Subjects = repository.for(:subject).all.take(8) - @Subjects.delete_if do |subject| - if subject.highlights.nil? || subject.highlights.empty? - true - end - end - @Subjects.each do |subject| - object = repository.for(:learning_object).find(subject.highlights.first) - end - + @Subjects = repository.for(:subject).all + @Subjects.delete_if{|s| not s.highlights.present?} + @Subjects = @Subjects.take(8) end def faq @@ -30,4 +21,10 @@ class WelcomeController < ApplicationController def contact end + + private + + def carousel_repository + repository.for :carousel + end end diff --git a/app/helpers/management/carousel_helper.rb b/app/helpers/management/carousel_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..d764ece79ca86f013cdc68b230deefd2789f3c99 --- /dev/null +++ b/app/helpers/management/carousel_helper.rb @@ -0,0 +1,2 @@ +module Management::CarouselHelper +end diff --git a/app/models/carousel.rb b/app/models/carousel.rb new file mode 100644 index 0000000000000000000000000000000000000000..e8a81d995ee3d9d870b2e3915ac5032f5cc35ab6 --- /dev/null +++ b/app/models/carousel.rb @@ -0,0 +1,7 @@ +class Carousel < ActiveRecord::Base + has_attached_file :image, styles: { + larger: "600x600>", + thumbnail: "100x100>" + }, default_url: "/images/:style/missing.png" + validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/ +end diff --git a/app/models/web_link.rb b/app/models/web_link.rb deleted file mode 100644 index 3b84a2845d055d33d17e474c244081721a5bacfe..0000000000000000000000000000000000000000 --- a/app/models/web_link.rb +++ /dev/null @@ -1,4 +0,0 @@ -class WebLink - include ActiveModel::Model - attr_accessor :id, :created_at, :description, :name, :thumbnail, :url -end \ No newline at end of file diff --git a/app/repositories/active_record/carousel_repository.rb b/app/repositories/active_record/carousel_repository.rb index b1a400103c2ec505822c41a9b8b0ddbd0c9ed05b..d0cdb267604d8bdbc0de9ec301352e489179212b 100644 --- a/app/repositories/active_record/carousel_repository.rb +++ b/app/repositories/active_record/carousel_repository.rb @@ -1,14 +1,14 @@ -module ActiveRecord - class CarouselRepository +## +# This carousel repository delegates all behavior to ActiveRecord +class ActiveRecord::CarouselRepository - def all - end - - def find - end + def method_missing(method_name, *arguments, &block) + Carousel.send(method_name, *arguments, &block) + end - def insert_data(name, url) - end + def respond_to?(method_name, include_private = false) + Carousel.respond_to?(method_name) || super end + end diff --git a/app/repositories/orient_db/highlight_repository.rb b/app/repositories/orient_db/highlight_repository.rb deleted file mode 100644 index df41d9764e042a2551f42bf0a916187ac6400662..0000000000000000000000000000000000000000 --- a/app/repositories/orient_db/highlight_repository.rb +++ /dev/null @@ -1,18 +0,0 @@ -module OrientDb - class HighlightRepository < Base - - def all - connection.query "Select highlights FROM MainPage" - end - - def insert_data (name, url) - connection.command "INSERT INTO Highlight (name,URL) VALUES ('#{name}','#{url}')" - end - - - def destroy_data(id) - @connection.command "DELETE VERTEX Highlight where @rid = '#{id}'" - end - - end -end diff --git a/app/repositories/orient_db/subject_repository.rb b/app/repositories/orient_db/subject_repository.rb index 27fedfb0a0f0fd44edf79edc6e995841d3623f68..b90fa2b919efcb4a884cb3ea1a2c9744decef128 100644 --- a/app/repositories/orient_db/subject_repository.rb +++ b/app/repositories/orient_db/subject_repository.rb @@ -39,7 +39,7 @@ module OrientDb subject = Subject.new(:id => args["@rid"]) args.each do |var, val| var_name = "@"+var - if subject.respond_to?(var) + if subject.respond_to?(var) && var != 'highlights' subject.instance_variable_set(var_name, val) end end diff --git a/app/views/management/carousels/_form.html.erb b/app/views/management/carousels/_form.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..9c4fa033325ca034ee30381bc9fdc017379a6001 --- /dev/null +++ b/app/views/management/carousels/_form.html.erb @@ -0,0 +1,41 @@ +<%= form_for([:management, @carousel], html: {class: 'ls-form row'}) do |f| %> + + <% if @carousel.errors.any? %> + <div class="ls-alert-danger"> + <h2><%= pluralize(@carousel.errors.count, "erro") %> <%= "happened".pluralize(@carousel.errors.count) %>:</h2> + <ul> + <% @carousel.errors.full_messages.each do |message| %> + <li><%= message %></li> + <% end %> + </ul> + </div> + <% end %> + + <fieldset> + <label class="ls-label col-md-3"> + <b class="ls-label-text">TÃtulo</b> + + <p>Digite o titulo deste destaque</p> + <%= f.text_field :title, {required: true} %> + </label> + <label class="ls-label col-md-5"> + <b class="ls-label-text">URL</b> + + <p>Digite a URL que o usuário será redirecionado</p> + <%= f.url_field :url, {required: true} %> + </label> + + <label class="ls-label col-md-5"> + <b class="ls-label-text">Imagem</b> + + <p>Escolha uma imagem para o destaque</p> + <%= f.file_field :image %> + </label> + </fieldset> + + <div class="ls-actions-btn"> + <button class="ls-btn">Salvar</button> + <%= link_to "Cancelar", management_carousels_path,class: "ls-btn-danger"%> + </div> + +<% end %> diff --git a/app/views/management/carousels/edit.html.erb b/app/views/management/carousels/edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e4195ad934da723acd597466b952f9b07b96a7b7 --- /dev/null +++ b/app/views/management/carousels/edit.html.erb @@ -0,0 +1,8 @@ +<h1 class="ls-title-intro ls-ico-users">Carousels</h1> + +<ol class="ls-breadcrumb"> + <li><%= link_to 'Carousels', management_carousels_path %></li> + <li>Administrar</li> +</ol> + +<%= render 'form' %> diff --git a/app/views/management/carousels/index.html.erb b/app/views/management/carousels/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..7f36d3e0d777f652869e7cd9a40696d1f7ff0a99 --- /dev/null +++ b/app/views/management/carousels/index.html.erb @@ -0,0 +1,45 @@ +<h1 class="ls-title-intro ls-ico-users">Carousels</h1> + +<a href="<%= new_management_carousel_path %>" class="ls-btn-primary" aria-expanded="false" role="combobox">Cadastrar + novo</a> +<table class="ls-table"> + <thead> + <tr> + <th> + Imagem + </th> + <th>TÃtulo</th> + <th> + URL + </th> + <th> + </th> + <th></th> + </tr> + </thead> + <tbody> + + <% @carousels.each do |c| %> + <tr> + <td> + <%= image_tag c.image.url(:thumbnail) %> + </td> + + <td> + <%= c.title %> + </td> + <td> + <%= c.url %> + </td> + + <td class="ls-txt-right ls-regroup"> + <%= link_to 'Modificar', edit_management_carousel_path(c) %> + </td> + <td> + <%= link_to 'Excluir', management_carousel_path(c), {method: :delete, data: {confirm: 'Tem certeza que deseja excluir?'}, title: 'Apagar usuário', class: 'ls-color-danger', role: 'option'} %> + </td> + </tr> + <% end %> + + </tbody> +</table> diff --git a/app/views/management/carousels/new.html.erb b/app/views/management/carousels/new.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..5cac49569c1a8729509a601370ed1d1bc9bfc4f7 --- /dev/null +++ b/app/views/management/carousels/new.html.erb @@ -0,0 +1,8 @@ +<h1 class="ls-title-intro ls-ico-users">Usuários</h1> + +<ol class="ls-breadcrumb"> + <li><a href="#">Usuários</a></li> + <li>Novo usuário</li> +</ol> + +<%= render 'form' %> \ No newline at end of file diff --git a/app/views/management/highlights/_form_delete.html.erb b/app/views/management/highlights/_form_delete.html.erb deleted file mode 100644 index 58312ed0bc411e780c6fc336fcdda0084da9717f..0000000000000000000000000000000000000000 --- a/app/views/management/highlights/_form_delete.html.erb +++ /dev/null @@ -1,33 +0,0 @@ - -<body> - -<div> - <class="ls-info-header"> - <class="ls-title-2"><h3>Remover destaque</h3><br> - - - - <%= form_tag(:action => "destroy", :method => "get") do %> - <fieldset> -<!-- Exemplo com Radio button --> - <div class="ls-label col-md-5"> - <p>Escolha os destaques a remover:</p> - <% @highlights.each do |highlight| %> - <label class="ls-label-text"> - <input type="checkbox" name="id[]" value= <%= highlight['@rid'] %>> - <%= highlight['name'] %> - </label> - <%end%> - </div> - </fieldset> - - - <div class="ls-actions-btn"> - <%= submit_tag "Salvar", class: "ls-btn" %> - <%= link_to "Cancelar", management_highlights_index_path, class: "ls-btn-danger" %> - </div> - <%end%> -</div> - - -</body> diff --git a/app/views/management/highlights/_form_new.html.erb b/app/views/management/highlights/_form_new.html.erb deleted file mode 100644 index ad4e8e5092da2ff313ebd84d61f3854f5e521879..0000000000000000000000000000000000000000 --- a/app/views/management/highlights/_form_new.html.erb +++ /dev/null @@ -1,43 +0,0 @@ -<body> - <div> - <!-- - <class="ls-info-header"> - <class="ls-title-2"><h3>Adicionar destaque</h3><br> - - <form action="" class="ls-form row"> - <fieldset> - <label class="ls-label col-md-3"> - <b class="ls-label-text">TÃtulo</b> - <p>Digite o tÃtulo do destaque</p> - <input type="text" name="name" placeholder="TÃtulo" required > - </label> - <label class="ls-label col-md-4"> - <b class="ls-label-text">URL</b> - <p>Cole a url do destaque no portal</p> - <input type="url" name="url" placeholder="URL do destaque no portal" required > - </label> - - </fieldset> - </form> ---> - - - - <%= form_tag( :action => "create", method: "post") do %> - <%= label_tag :name, "TÃtulo do destaque" %><br><br> - <%= text_field_tag :name,'', placeholder: "tÃtulo " %> - <br><br><br> - - <%= label_tag :url, "URL da coleção no portal" %><br><br> - <%= text_field_tag :url, '', placeholder: "url" %> - <%= submit_tag "Salvar", class: "ls-btn" %> - - <% end %> - - -<div class="ls-actions-btn"> - - <%= link_to "Cancelar", management_highlights_index_path, class: "ls-btn-danger" %> - -</div> -</body> diff --git a/app/views/management/highlights/delete.html.erb b/app/views/management/highlights/delete.html.erb deleted file mode 100644 index d1a58f61228d1a95c4808227b39ce450e7f9f6cc..0000000000000000000000000000000000000000 --- a/app/views/management/highlights/delete.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<ol class="ls-breadcrumb"> - <li><%= link_to "InÃcio", management_root_path %></li> - <li><%= link_to "Destaques", management_highlights_index_path %></li> - <li> Remover </li> -</ol> -<br> - -<%= render 'form_delete' %> diff --git a/app/views/management/highlights/index.html.erb b/app/views/management/highlights/index.html.erb deleted file mode 100644 index 36865eb4f5d4c001462b1fc26df0c992d3d85ac0..0000000000000000000000000000000000000000 --- a/app/views/management/highlights/index.html.erb +++ /dev/null @@ -1,45 +0,0 @@ - - - -<ol class="ls-breadcrumb"> - <li><%= link_to "InÃcio", management_root_path %></li> - <li> Destaques </li> -</ol> -<br> - -<div> - <header class="ls-info-header"> - <h2 class="ls-title-3">Destaques</h2> - <p class="ls-float-right ls-float-none-xs ls-small-info"> <strong><%= Date.today.to_s %></strong></p> - </header> - -</div> - - - - - <div class="ls-list-title "> - <b>Destaques atuais no carrosel:</b> - </div> - <div class="ls-list-description"> - <ul> - <% if @highlights.present? %> - <% @highlights.each do |highlight| %> - <br> - <li> <%= highlight['name'] %></li> - <% end %> - <% else %> - <li> - Não existe nenhuma destaque ainda. - </li> - <%end%> - </ul> - </div> - - - -<br><br><br> -<%= link_to "Adicionar destaques", management_highlights_new_path, class: "ls-btn ls-btn-lg" %> - - -<%= link_to "Remover destaques", management_highlights_delete_path, class: "ls-btn ls-btn-lg" %> diff --git a/app/views/management/highlights/new.html.erb b/app/views/management/highlights/new.html.erb deleted file mode 100644 index 9356f7932651a572f51416b85b2d8b48e9978c02..0000000000000000000000000000000000000000 --- a/app/views/management/highlights/new.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<ol class="ls-breadcrumb"> - <li><%= link_to "InÃcio", management_root_path %></li> - <li><%= link_to "Destaques", management_highlights_index_path %></li> - <li> Novo </li> -</ol> -<br> - -<%= render 'form_new' %> diff --git a/app/views/shared/management/_nav_menu.html.erb b/app/views/shared/management/_nav_menu.html.erb index 3b8b8e725bf19176df73c3708fbb023960be7485..01b4e8606c969db6eee41bf4a07dc0a7730a9b3e 100644 --- a/app/views/shared/management/_nav_menu.html.erb +++ b/app/views/shared/management/_nav_menu.html.erb @@ -1,7 +1,7 @@ <nav class="ls-menu"> <ul> <li><%= link_to "InÃcio", management_root_path, class: 'ls-ico-home' %></li> - <li><%= link_to "Objetos em destaque", management_highlights_path, class: 'ls-ico-star' %> + <li><%= link_to "Objetos em destaque", management_carousels_path, class: 'ls-ico-star' %> <li> <li class="ls-submenu"> @@ -25,4 +25,4 @@ <li><%= link_to "Denúncias", '#', class: 'ls-ico-bullhorn' %> <li> </ul> -</nav> \ No newline at end of file +</nav> diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 3d5cd8b6f7700a5292e3143d26f39907cf6ea4d5..61f5baf9c874a36a4b2bfd853eef62a6269791ce 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -23,12 +23,11 @@ <% highlight_class="item" %> <% end %> <div class="<%= highlight_class %>"> - <%= image_tag 'mecshow_logo.jpg'%> + <%= image_tag highlight.image.url(:larger) %> <div class="container"> <div class="carousel-caption"> - <h1><%= highlight['title'] %></h1> - <p id="carrousel-new-description"><%= highlight['description'] %> </p> - <p><a class="btn btn-lg btn-primary" href=<%= highlight['URL'] %> role="button">Mais informações</a></p> + <h1><%= highlight.title %></h1> + <p><a class="btn btn-lg btn-primary" href=<%= highlight.url %> role="button">Mais informações</a></p> </div> </div> </div> @@ -49,7 +48,7 @@ <% if @General.present? %> <ul class="list-unstyled"> <h2>Destaques</h2> - <%= render @General %> + <%= render @General, orientation: 'horizontal' %> <% end %> </ul> </div> @@ -67,8 +66,8 @@ <% @Subjects.each do |subject|%> <div class="col-sm-4"> <div class="row"> - <h4><b><%= subject["name"] %></b></h4> - <%= render 'shared/application/object_vertical', object: subject["first_highlight"] %> + <h4><b><%= subject.name %></b></h4> + <%= render subject.highlights.first, orientation: 'vertical'%> <p> <a href="#">Ver Mais</a> </p> @@ -78,4 +77,4 @@ </div> <% end %> </div> -</div> +</div> \ No newline at end of file diff --git a/config/initializers/repositories/repositories.rb b/config/initializers/repositories/repositories.rb index bc014e7c0215152ef0799b463f60a7531a847f6c..f6666e218bec5ea09b18d95b0217612a57577a43 100644 --- a/config/initializers/repositories/repositories.rb +++ b/config/initializers/repositories/repositories.rb @@ -22,19 +22,19 @@ end Repository::Environments.create :development do |repository| repository.register :learning_object, OrientDb::LearningObjectRepository.new(OrientDb::Client.instance) repository.register :mainPage, OrientDb::MainPageRepository.new(OrientDb::Client.instance) - repository.register :webLink, OrientDb::WeblinkRepository.new(OrientDb::Client.instance) repository.register :user, UserRepositoryProxy.new(OrientDb::UserRepository.new(OrientDb::Client.instance)) repository.register :subject, OrientDb::SubjectRepository.new(OrientDb::Client.instance) repository.register :institution, OrientDb::InstitutionRepository.new(OrientDb::Client.instance) repository.register :subject, OrientDb::SubjectRepository.new(OrientDb::Client.instance) repository.register :attribute, OrientDb::AttributeRepository.new(OrientDb::Client.instance) repository.register :collection, OrientDb::CollectionRepository.new(OrientDb::Client.instance) + repository.register :carousel, ActiveRecord::CarouselRepository.new end Repository::Environments.create :test do |repository| + repository.register :carousel, ActiveRecord::CarouselRepository.new repository.register :learning_object, OrientDb::LearningObjectRepository.new(OrientDb::Client.instance) repository.register :mainPage, OrientDb::MainPageRepository.new(OrientDb::Client.instance) - repository.register :webLink, OrientDb::WeblinkRepository.new(OrientDb::Client.instance) repository.register :user, UserRepositoryProxy.new(OrientDb::UserRepository.new(OrientDb::Client.instance)) repository.register :subject, OrientDb::SubjectRepository.new(OrientDb::Client.instance) repository.register :attribute, OrientDb::AttributeRepository.new(OrientDb::Client.instance) @@ -42,9 +42,9 @@ Repository::Environments.create :test do |repository| end Repository::Environments.create :production do |repository| + repository.register :carousel, ActiveRecord::CarouselRepository.new repository.register :learning_object, OrientDb::LearningObjectRepository.new(OrientDb::Client.instance) repository.register :mainPage, OrientDb::MainPageRepository.new(OrientDb::Client.instance) - repository.register :webLink, OrientDb::WeblinkRepository.new(OrientDb::Client.instance) repository.register :user, UserRepositoryProxy.new(OrientDb::UserRepository.new(OrientDb::Client.instance)) repository.register :subject, OrientDb::SubjectRepository.new(OrientDb::Client.instance) repository.register :attribute, OrientDb::AttributeRepository.new(OrientDb::Client.instance) diff --git a/config/routes.rb b/config/routes.rb index 5c3f7e86580c75626b2927212ae189996dfc6363..597cf4ff4424ca60fa87624a09dd04e2afbf84ce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -18,7 +18,7 @@ Rails.application.routes.draw do end resources :users - resources :highlights + resources :carousels end root 'welcome#index' @@ -34,6 +34,7 @@ Rails.application.routes.draw do resources :subjects, only: [:index, :show] get 'users/:id', to: 'users#show', as: 'users_show' + get '/faq' => 'welcome#faq' get '/contact' => 'welcome#contact', as: 'contact' get '/complaint' => 'welcome#complaint', as: 'complaint' diff --git a/db/migrate/20150922141008_create_carousels.rb b/db/migrate/20150922141008_create_carousels.rb new file mode 100644 index 0000000000000000000000000000000000000000..4e0e3bfa95e6d95a57b3691e5af9d560a6007063 --- /dev/null +++ b/db/migrate/20150922141008_create_carousels.rb @@ -0,0 +1,10 @@ +class CreateCarousels < ActiveRecord::Migration + def change + create_table :carousels do |t| + t.string :title + t.text :url + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20150922141009_add_image_column_to_carousels.rb b/db/migrate/20150922141009_add_image_column_to_carousels.rb new file mode 100644 index 0000000000000000000000000000000000000000..704b097e49bb25c7fee7edba4d2369b8b59d9fcd --- /dev/null +++ b/db/migrate/20150922141009_add_image_column_to_carousels.rb @@ -0,0 +1,9 @@ +class AddImageColumnToCarousels < ActiveRecord::Migration + def up + add_attachment :carousels, :image + end + + def down + remove_attachment :carousels, :image + end +end diff --git a/test/controllers/management/carousel_controller_test.rb b/test/controllers/management/carousel_controller_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..5ef47df22551ab99c7d5e8bfd325783d84fc806a --- /dev/null +++ b/test/controllers/management/carousel_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class Management::CarouselControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/fixtures/carousels.yml b/test/fixtures/carousels.yml new file mode 100644 index 0000000000000000000000000000000000000000..874eb455b15023db983a48bf8a96c01aaa9acde1 --- /dev/null +++ b/test/fixtures/carousels.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + title: MyString + url: MyText + +two: + title: MyString + url: MyText diff --git a/test/models/carousel_test.rb b/test/models/carousel_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..26c20b1e122e221fdec4d8ab8789e1a060cbeb11 --- /dev/null +++ b/test/models/carousel_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CarouselTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end