Commit 09b64583 by Mykhailo Makohin

some progress in creating contribution

parent 8cee214d
...@@ -23,7 +23,7 @@ gem 'haml' ...@@ -23,7 +23,7 @@ gem 'haml'
gem 'bootstrap-sass' gem 'bootstrap-sass'
gem 'gmaps4rails' gem 'gmaps4rails'
gem 'remotipart' gem 'remotipart'
gem 'simple_form' gem 'simple_form', '~> 5.0', '>= 5.0.1'
gem 'activeadmin' gem 'activeadmin'
gem 'carrierwave' gem 'carrierwave'
gem 'cancancan' gem 'cancancan'
......
...@@ -270,7 +270,7 @@ GEM ...@@ -270,7 +270,7 @@ GEM
tilt (>= 1.1, < 3) tilt (>= 1.1, < 3)
sassc (2.2.1) sassc (2.2.1)
ffi (~> 1.9) ffi (~> 1.9)
simple_form (4.1.0) simple_form (5.0.1)
actionpack (>= 5.0) actionpack (>= 5.0)
activemodel (>= 5.0) activemodel (>= 5.0)
spring (2.0.2) spring (2.0.2)
...@@ -353,7 +353,7 @@ DEPENDENCIES ...@@ -353,7 +353,7 @@ DEPENDENCIES
ransack ransack
remotipart remotipart
sass-rails (~> 5.0) sass-rails (~> 5.0)
simple_form simple_form (~> 5.0, >= 5.0.1)
spring spring
spring-watcher-listen (~> 2.0.0) spring-watcher-listen (~> 2.0.0)
turbolinks (~> 5) turbolinks (~> 5)
......
...@@ -72,7 +72,7 @@ ActiveAdmin.register Project do ...@@ -72,7 +72,7 @@ ActiveAdmin.register Project do
form html: { multipart: true } do |f| form html: { multipart: true } do |f|
f.inputs do f.inputs do
f.input :aasm_state, as: :select, collection: [:approved, :display], label: 'State' f.input :aasm_state, as: :select, collection: [:approved, :show], label: 'State'
f.input :photo, label: "#{t "active_admin.attributes.project.photo"}", f.input :photo, label: "#{t "active_admin.attributes.project.photo"}",
hint: f.object.photo.present? ? image_tag(f.object.photo.url(:thumb_small)) : content_tag(:span, "no file yet") hint: f.object.photo.present? ? image_tag(f.object.photo.url(:thumb_small)) : content_tag(:span, "no file yet")
f.input :photo_preview, label: "#{t "active_admin.attributes.project.photo_preview"}", f.input :photo_preview, label: "#{t "active_admin.attributes.project.photo_preview"}",
......
...@@ -51,10 +51,10 @@ function initBookmarkAnimation(){ ...@@ -51,10 +51,10 @@ function initBookmarkAnimation(){
function initLoadMore(){ function initLoadMore(){
$(document).ready(function(){ $(document).ready(function(){
$(".project_item_content").slice(0, 4).show(); $(".project_item_content").slice(0, 2).show();
$("#loadMore").on("click", function(e){ $("#loadMore").on("click", function(e){
e.preventDefault(); e.preventDefault();
$(".project_item_content:hidden").slice(0, 4).slideDown(); $(".project_item_content:hidden").slice(0, 2).slideDown();
if($(".project_item_content:hidden").length == 0) { if($(".project_item_content:hidden").length == 0) {
$("#loadMore").text("No Content").addClass("noContent"); $("#loadMore").text("No Content").addClass("noContent");
} }
......
class ContributionsController < ApplicationController
def create
@contrbution = Contribution.create(contribition_params)
if @contrbution.save
redirect_to root_path
else
head :ok
end
end
private
def contribition_params
params.require(:contribution).permit(:contribution, :project_id, :user_id)
end
end
\ No newline at end of file
class HomeController < ApplicationController class HomeController < ApplicationController
def index def index
@q = Project.ransack(params[:q]) if params[:limit].blank?
@projects = @q.result(distinct: true) limit = 4
else
limit = params[:limit]
end
@q = Project.ransack(params[:q])
@projects = @q.result.limit(limit)
@projects = Project.ransack(params[{"q"=>{"s"=>"created_at desc"}}]).result.limit(limit) unless params[:q]
end end
end end
class Contribution < ApplicationRecord
belongs_to :user
belongs_to :project
validates :contribution, presence: true
end
...@@ -4,14 +4,14 @@ class Project < ApplicationRecord ...@@ -4,14 +4,14 @@ class Project < ApplicationRecord
aasm do aasm do
state :registered, initial: true state :registered, initial: true
state :approved, :display state :approved, :show
event :approved do event :approved do
transitions from: [:registered, :display], to: :approved transitions from: [:registered, :show], to: :approved
end end
event :display do event :show do
transitions from: [:registered, :approved], to: :display transitions from: [:registered, :approved], to: :show
end end
end end
...@@ -30,6 +30,7 @@ class Project < ApplicationRecord ...@@ -30,6 +30,7 @@ class Project < ApplicationRecord
enum types: [:program, :project] enum types: [:program, :project]
enum status: [:in_progress, :implemented] enum status: [:in_progress, :implemented]
has_many :contributions
has_many :project_partials, -> { order(position: :asc) }, dependent: :destroy has_many :project_partials, -> { order(position: :asc) }, dependent: :destroy
has_many :project_galeries, inverse_of: :project, dependent: :destroy has_many :project_galeries, inverse_of: :project, dependent: :destroy
has_many :project_qoutes, inverse_of: :project, dependent: :destroy has_many :project_qoutes, inverse_of: :project, dependent: :destroy
......
class User < ApplicationRecord class User < ApplicationRecord
has_many :contributions
attr_accessor :skip_password_validation attr_accessor :skip_password_validation
after_initialize :set_default_role, :if => :new_record? after_initialize :set_default_role, :if => :new_record?
......
.container_lg .container_lg
.project_wrap.clearfix.content .project_wrap.clearfix.content
- @projects.each do |project| - @projects.each do |project|
= link_to project_path(id: project.id), remote: true, class: 'project_item' do = link_to project_path(project), class: 'project_item' do
%span.project_item_top %span.project_item_top
= image_tag(project.photo_preview_url(:thumb_small)) = image_tag(project.photo_preview_url(:thumb_small))
%span.item_label %span.item_label
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
%span.project_item_text= raw project.short_description %span.project_item_text= raw project.short_description
%span.project_item_bot %span.project_item_bot
%span.progress %span.progress
%span.progress-bar{"aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => "20", :role => "progressbar", :style => "width:20%"} %span.progress-bar{"aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => "20", role: "progressbar", style: "width:20%"}
%span.progress_value= t ('collected_money') %span.progress_value= t ('collected_money')
%span.progress_details.clearfix %span.progress_details.clearfix
%span.progress_details_item %span.progress_details_item
...@@ -23,4 +23,4 @@ ...@@ -23,4 +23,4 @@
%span.progress_details_item %span.progress_details_item
= t ('joined_people') = t ('joined_people')
%strong 214 %strong 214
%a.btn.btn_default.btn_bordered.btn_more{:href => "#"}= t ('more') = link_to "#{t ('more')}", root_path(limit: @projects.count + 1), remote: true, class: ' loadMore btn btn_default btn_bordered btn_more'
/ .container
/ .flex
/ .project_item_content Box 1
/ .project_item_content Box 2
/ .project_item_content Box 3
/ .project_item_content Box 4
/ .project_item_content Box 5
/ .project_item_content Box 1
/ .project_item_content Box 2
/ .project_item_content Box 3
/ .project_item_content Box 4
/ .project_item_content Box 5
/ .project_item_content Box 2
/ .project_item_content Box 3
/ .project_item_content Box 4
/ .project_item_content Box 5
/ %a#loadMore{:href => "#"} Load More
.wrapper .wrapper
.content .content
.main_head .main_head
...@@ -101,7 +84,7 @@ ...@@ -101,7 +84,7 @@
%span.grid_item_content.tooltipstered %span.grid_item_content.tooltipstered
%a.get_involved_link.centered{"data-original-title" => "приєднатись", "data-placement" => "top", "data-toggle" => "tooltip", :href => "#"} %a.get_involved_link.centered{"data-original-title" => "приєднатись", "data-placement" => "top", "data-toggle" => "tooltip", :href => "#"}
%span.get_involved_circle %span.get_involved_circle
%img.icon_plus{:alt => "", :src => "plus.svg"}/ %img.icon_plus{:alt => "", :src => ""}/
.progress .progress
.progress-bar{"aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => "58", :role => "progressbar", :style => "width: 58%"} .progress-bar{"aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => "58", :role => "progressbar", :style => "width: 58%"}
.progress_value_lg 58 / 100 .progress_value_lg 58 / 100
...@@ -192,6 +175,7 @@ ...@@ -192,6 +175,7 @@
= link_to "#{t ('implemented')}", '?q%5Bs%5D=status+desc', class: "btn", remote: true = link_to "#{t ('implemented')}", '?q%5Bs%5D=status+desc', class: "btn", remote: true
= link_to "#{t ('in_progress')}", '?q%5Bs%5D=status+asc', class: "btn", remote: true = link_to "#{t ('in_progress')}", '?q%5Bs%5D=status+asc', class: "btn", remote: true
#projects_list #projects_list
= render 'projects'
.section.section_advert .section.section_advert
.container .container
.row .row
......
$("#projects_list").html("#{ j(render 'projects') }"); $("#projects_list").html("#{ j(render 'projects')}");
\ No newline at end of file \ No newline at end of file
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
%link{:href => "//fonts.googleapis.com/css?family=Roboto:300,500&subset=cyrillic-ext", :rel => "stylesheet"} %link{:href => "//fonts.googleapis.com/css?family=Roboto:300,500&subset=cyrillic-ext", :rel => "stylesheet"}
%link{:href => "https://fonts.googleapis.com/css?family=Montserrat:300|Six+Caps", :rel => "stylesheet"} %link{:href => "https://fonts.googleapis.com/css?family=Montserrat:300|Six+Caps", :rel => "stylesheet"}
/Favicons + Touch Icons /Favicons + Touch Icons
%link{:href => "favicons/apple-touch-icon57.png", :rel => "icon", :type => "image/png"}
%link{:href => "favicons/apple-touch-icon57.png", :rel => "apple-touch-icon", :sizes => "57x57"} %link{:href => "favicons/apple-touch-icon57.png", :rel => "apple-touch-icon", :sizes => "57x57"}
%link{:href => "favicons/apple-touch-icon60.png", :rel => "apple-touch-icon", :sizes => "60x60"} %link{:href => "favicons/apple-touch-icon60.png", :rel => "apple-touch-icon", :sizes => "60x60"}
%link{:href => "favicons/apple-touch-icon114.png", :rel => "apple-touch-icon", :sizes => "114x114"} %link{:href => "favicons/apple-touch-icon114.png", :rel => "apple-touch-icon", :sizes => "114x114"}
......
...@@ -46,3 +46,59 @@ ...@@ -46,3 +46,59 @@
%i.icon.icon_google %i.icon.icon_google
.text-center .text-center
= f.button :submit, "Register Now", class: "btn btn-success btn-lg" = f.button :submit, "Register Now", class: "btn btn-success btn-lg"
= simple_form_for :contribution, remote: true, validate: true, url: contributions_path do |f|
= f.error_notification
#modal.modal.fade.modal_styled{"aria-labelledby" => "modalLabel", :role => "dialog", :tabindex => "-1"}
.modal-dialog{:role => "document"}
.modal-content
.modal-header
.modal-header_top.clearfix
.modal-header_top_bg
%button.round_link.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
%i.icon.icon_close
.modal-header_bot
.row
.col-sm-5
%h3#modalLabel.modal-title Фондування
.col-sm-7.modal-header_bot_amount
.form-group
= f.hidden_field :project_id, value: @project.id
= f.hidden_field :user_id, value: current_user.id
= f.input :contribution, label: 'Сума внеску в UAH', required: false, input_html: { class: 'form-group amount_field' }
= f.submit (t ('donate')), class: ' btn btn_primary'
/ .help_text.absolute
/ %span.asterisk *
/ Поля обов'язкові для заповнення
/ .modal-body.modal-body_pb
/ .row
/ .col-sm-9.modal-body_login
/ .form-group
/ %label{:for => "id_2"}
/ %span.asterisk> *
/ Ім'я та прізвище
/ .field_wrap
/ %input#id_2.form-control{:type => "text"}
/ .form-group
/ %label{:for => "id_3"}
/ %span.asterisk> *
/ E-mail
/ .field_wrap
/ %input#id_3.form-control{:type => "email"}
/ .form-group
/ %label{:for => "id_4"}
/ Населений пункт
/ .field_wrap
/ %input#id_4.form-control{:type => "text"}
/ .col-sm-3.modal-body_registration
/ %h4.modal_subtitle
/ Швидка авторизація
/ .soc_btn_wrap.clearfix
/ %a.soc_btn.soc_btn_fb{:href => "#"}
/ %i.icon.icon_fb
/ %a.soc_btn.soc_btn_tw{:href => "#"}
/ %i.icon.icon_tw
/ %a.soc_btn.soc_btn_google{:href => "#"}
/ %i.icon.icon_google
/ .text-center
/ %a.btn.btn_primary{:href => "#"} Далі
\ No newline at end of file
%header.header %header.header
.container .container
.main_menu .main_menu
%a.logo{:href => "#"} = link_to image_tag('logo.svg'), root_path, class: 'logo'
= image_tag ("logo.svg")
%nav.navbar.navbar-default %nav.navbar.navbar-default
.container-fluid .container-fluid
.navbar-header .navbar-header
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
.container .container
.text_container .text_container
= raw @project.description = raw @project.description
- unless @project.photo_before.blank? - unless @project.photo_before.blank?
#slider.beer-slider{"data-beer-label" => "before"} #slider.beer-slider{"data-beer-label" => "before"}
= image_tag(@project.photo_before_url) = image_tag(@project.photo_before_url)
.beer-reveal{"data-beer-label" => "after"} .beer-reveal{"data-beer-label" => "after"}
= image_tag(@project.photo_after.url) = image_tag(@project.photo_after.url)
.files_block .files_block
.container %ul.files_list.clearfix
%ul.files_list.clearfix .container
%li.file_item_wrap %li.file_item_wrap
%a.file_item{:href => "#"} %a.file_item{:href => "#"}
- @project.project_documents.each do |project_document| - @project.project_documents.each do |project_document|
......
...@@ -6,4 +6,4 @@ ...@@ -6,4 +6,4 @@
%ul.list %ul.list
%li %li
#{project_link.title} #{project_link.title}
%a{:href => "#{project_link.site}"} #{project_link.site} = link_to project_link.site
.slider .container
= image_tag("1_1.jpg", width: "100%") .imgs_wrap
= image_tag("1_2.jpg", width: "100%") .simple_slider.clearfix
.slider
- @project.project_photos.each do |project_photo|
= image_tag(project_photo.photo.url)
.wrapper .wrapper
.content .content
.head_block .head_block{:style => "background: transparent url(#{@project.photo.url}) no-repeat center center;background-size: cover; margin-bottom: 6px;"}
.container .container
.info_title .info_title
%span.info_title_text= t "#{@project.types}" %span.info_title_text= t "#{@project.types}"
%a.info_link{"data-target" => "#modal3", "data-toggle" => "modal", :href => "#"} #{@project.site} %a.info_link #{@project.site}
%h2.heading_with_btn %h2.heading_with_btn
%span #{@project.title} %span #{@project.title}
%a.btn.btn_default{"data-target" => "#modal", "data-toggle" => "modal", :href => "#"} %a.btn.btn_default{"data-target" => "#modal", "data-toggle" => "modal", :href => "#"}
...@@ -14,13 +14,61 @@ ...@@ -14,13 +14,61 @@
.large_progress_title .large_progress_title
= t "#{@project.status}" = t "#{@project.status}"
.project_content .project_content
.project_partials
- @project.project_partials.order(:position).each do |project_partial|
- if @project.send("#{project_partial.title}").present?
%ul
%li
= render "#{project_partial.title}"
.support_block{:style => "background: transparent url(#{@project.footer_photo.url}) no-repeat center center; padding: 30px 0 20px; background-size: cover;"}
.container .container
%div.project_partials %h2.heading_with_btn
- @project.project_partials.order(:position).each do |project_partial| %span #{@project.title}
- if @project.send("#{project_partial.title}").present? %a.btn.btn_default{:href => "#"}
%ul %i.icon.icon_plus>
%li підтримати проект
= render "#{project_partial.title}" .news_wrap
.container.grid_padding_xs
%h3.heading_mb
Новини про проект
.row
.col-sm-4
%a.news_item{:href => "#"}
%span.news_head
= image_tag('news1.jpg')
%span.news_details.clearfix
Новина
%span.news_date 12.12.15
%span.news_body
%span.news_title
Гранти — грошові або інші засоби, що передаються
%span.news_text
Грaнти — грошові або інші засоби, що передаються громадянами юридиими також міжнародними організаціями
проведення конкретних наукових...
.col-sm-4
%a.news_item{:href => "#"}
%span.news_head
= image_tag('news2.jpg')
%span.news_details.clearfix
Публікація
%span.news_date 12.12.15
%span.news_body
%span.news_title
Публікація про важливе.
%span.news_text
Досліджень, розробки законопроектів, підготовки кадрів та інших цілей на умовах, передбачених грантодавцем. Гранти надаються безкоштовно і без повернення для осіб...
.col-sm-4
%a.news_item{:href => "#"}
%span.news_head
= image_tag('news3.jpg')
%span.news_details.clearfix
Блоги
%span.news_date 12.12.15
%span.news_body
%span.news_title
У випадку довгого заголовка який не бажано обрізати чи вкорочувати, буде так
%span.news_text
Досліджень, розробки законопроектів, підготовки кадрів та інших цілей на умовах, передбачених грантодавцем.
:javascript :javascript
new BeerSlider( document.getElementById( "slider" ) ); new BeerSlider( document.getElementById( "slider" ) );
......
...@@ -5,6 +5,7 @@ Rails.application.routes.draw do ...@@ -5,6 +5,7 @@ Rails.application.routes.draw do
put "/admin/projects/:id", to: 'admin/projects#sort' put "/admin/projects/:id", to: 'admin/projects#sort'
ActiveAdmin.routes(self) ActiveAdmin.routes(self)
resources :users resources :users
resources :contributions, only: [:create]
resources :projects, only: [:show] resources :projects, only: [:show]
end end
devise_for :users, controllers: {omniauth_callbacks: "users/omniauth_callbacks", devise_for :users, controllers: {omniauth_callbacks: "users/omniauth_callbacks",
......
class CreateContributions < ActiveRecord::Migration[5.0]
def change
create_table :contributions do |t|
t.integer :contribution
t.references :user
t.references :project
t.timestamps
end
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20191024074653) do ActiveRecord::Schema.define(version: 20191031114255) do
create_table "active_admin_comments", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "active_admin_comments", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "namespace" t.string "namespace"
...@@ -38,6 +38,16 @@ ActiveRecord::Schema.define(version: 20191024074653) do ...@@ -38,6 +38,16 @@ ActiveRecord::Schema.define(version: 20191024074653) do
t.index ["type"], name: "index_ckeditor_assets_on_type", using: :btree t.index ["type"], name: "index_ckeditor_assets_on_type", using: :btree
end end
create_table "contributions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.integer "contribution"
t.integer "user_id"
t.integer "project_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["project_id"], name: "index_contributions_on_project_id", using: :btree
t.index ["user_id"], name: "index_contributions_on_user_id", using: :btree
end
create_table "friendly_id_slugs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "friendly_id_slugs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "slug", null: false t.string "slug", null: false
t.integer "sluggable_id", null: false t.integer "sluggable_id", null: false
......
...@@ -9699,11 +9699,11 @@ h2 { ...@@ -9699,11 +9699,11 @@ h2 {
font-weight: 700; font-weight: 700;
color: #fff; color: #fff;
} }
.head_block { /*.head_block {
background: transparent url(head_block_bg.jpg) no-repeat center center; background: transparent url(head_block_bg.jpg) no-repeat center center;
background-size: cover; background-size: cover;
margin-bottom: 6px; margin-bottom: 6px;
} }*/
.info_title { .info_title {
padding-top: 31px; padding-top: 31px;
} }
...@@ -9938,11 +9938,11 @@ h3 { ...@@ -9938,11 +9938,11 @@ h3 {
.file_item_wrap:nth-child(even) { .file_item_wrap:nth-child(even) {
padding-left: 41px; padding-left: 41px;
} }
.support_block { /*.support_block {
background: transparent url(support_block_bg.jpg) no-repeat center center; background: transparent url(support_block_bg.jpg) no-repeat center center;
padding: 30px 0 20px; padding: 30px 0 20px;
background-size: cover; background-size: cover;
} }*/
.news_wrap { .news_wrap {
padding: 30px 0 86px; padding: 30px 0 86px;
} }
...@@ -11604,7 +11604,7 @@ h1 { ...@@ -11604,7 +11604,7 @@ h1 {
padding-bottom: 36px; padding-bottom: 36px;
} }
.project_item { .project_item {
width: calc(20% - 20.4px); width: 299px;
float: left; float: left;
margin: 0 10px 20px; margin: 0 10px 20px;
background-color: #fff; background-color: #fff;
...@@ -13877,7 +13877,7 @@ _::-webkit-full-page-media, _:future, :root .add_sign { ...@@ -13877,7 +13877,7 @@ _::-webkit-full-page-media, _:future, :root .add_sign {
========================================================================== */ ========================================================================== */
@media (max-width: 1600px) { @media (max-width: 1600px) {
.project_item { .project_item {
width: calc(25% - 20.4px); width: 299px;
} }
.link_primary + .link_primary { .link_primary + .link_primary {
margin-left: 120px; margin-left: 120px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment