hatchy 0.0.5.pre → 0.0.6.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +68 -0
  3. data/app/assets/javascripts/hatchy/admin.js +7 -0
  4. data/app/controllers/hatchy/admin/projects_controller.rb +58 -0
  5. data/app/controllers/hatchy/admin/users_controller.rb +47 -0
  6. data/app/controllers/hatchy/projects_controller.rb +1 -1
  7. data/app/controllers/hatchy/users_controller.rb +1 -1
  8. data/app/datatables/hatchy/contributions_datatable.rb +68 -0
  9. data/app/datatables/hatchy/projects_datatable.rb +71 -0
  10. data/app/datatables/hatchy/users_datatable.rb +70 -0
  11. data/app/models/concerns/hatchy/project_states.rb +4 -5
  12. data/app/models/hatchy/project.rb +1 -1
  13. data/app/views/hatchy/admin/projects/_about.html.haml +8 -0
  14. data/app/views/hatchy/admin/projects/_basic_info.html.haml +55 -0
  15. data/app/views/hatchy/admin/projects/_project_account.html.haml +34 -0
  16. data/app/views/hatchy/admin/projects/index.html.haml +25 -0
  17. data/app/views/hatchy/admin/projects/show.html.haml +22 -0
  18. data/app/views/hatchy/admin/users/_basic_info.html.haml +54 -0
  19. data/app/views/hatchy/admin/users/_contributions.html.haml +25 -0
  20. data/app/views/hatchy/admin/users/_projects.html.haml +31 -0
  21. data/app/views/hatchy/admin/users/index.html.haml +24 -0
  22. data/app/views/hatchy/admin/users/show.html.haml +20 -0
  23. data/lib/generators/hatchy/install_generator.rb +24 -0
  24. data/lib/generators/templates/hatchy.rb +4 -0
  25. data/lib/hatchy.rb +8 -0
  26. data/lib/hatchy/version.rb +1 -1
  27. data/lib/tasks/hatchy_tasks.rake +11 -1
  28. data/spec/controllers/hatchy/admin/projects_controller_spec.rb +7 -0
  29. data/spec/controllers/hatchy/admin/users_controller_spec.rb +7 -0
  30. data/spec/dummy/db/development.sqlite3 +0 -0
  31. data/spec/dummy/log/development.log +40926 -0
  32. data/spec/dummy/public/uploads/hatchy/project/project_img/2/Kickstarter-games.jpg +0 -0
  33. data/spec/dummy/tmp/cache/assets/development/sprockets/69d0e5fd934e4f651c4126e0e7c8994f +0 -0
  34. data/spec/dummy/tmp/cache/assets/development/sprockets/7cba22a2cfc1f0a02bf5fa3a0e4e5a27 +0 -0
  35. data/spec/dummy/tmp/cache/assets/development/sprockets/8e08251664adb259d48c3ff9019fb9cf +0 -0
  36. data/spec/dummy/tmp/cache/assets/development/sprockets/adf03687ee42f87002445c1096069d64 +0 -0
  37. data/spec/dummy/tmp/cache/assets/development/sprockets/bde5827fcb5ae18fd1ca1c57386417be +0 -0
  38. data/spec/dummy/tmp/cache/assets/development/sprockets/c37311498380e52a91dbfc2c96425eac +0 -0
  39. data/spec/dummy/tmp/cache/assets/development/sprockets/d11f4f73ecc91eb895ed1a2da31f13ba +0 -0
  40. data/spec/dummy/tmp/cache/assets/development/sprockets/d41f33e5d0faf16d0549d1a45aef4f06 +0 -0
  41. data/spec/dummy/tmp/cache/assets/development/sprockets/fb4485de1e413169e29fd17a5549b7d5 +0 -0
  42. metadata +52 -3
  43. data/lib/hatchy/setup_generator.rb +0 -10
@@ -48,7 +48,7 @@ module Hatchy::ProjectStates
48
48
 
49
49
  def push_to_trash
50
50
  if self.status == "draft" or self.status == "rejected" or self.status == "analysis"
51
- self.status = "deleted"
51
+ self.status = "trash"
52
52
  else
53
53
  self.errors[:status] << "Project must be in draft, rejected or analysis first to be deleted"
54
54
  end
@@ -147,10 +147,9 @@ module Hatchy::ProjectStates
147
147
  account_attributes:[
148
148
  :account, :account_digit, :account_type,
149
149
  :address_city, :address_number, :address_state,
150
- :address_street,:address_zip, :agency,
151
- :agency_digit, :bank_id, :email,
152
- :owner_document,:owner_name, :phone,
153
- :project_id
150
+ :address_street,:address_zip, :bank_id,
151
+ :email, :owner_document, :owner_name,
152
+ :phone, :project_id
154
153
  ]
155
154
  ]
156
155
  end
@@ -16,7 +16,7 @@ module Hatchy
16
16
  validates :name, presence: true, uniqueness: true
17
17
 
18
18
  scope :recommended, -> { where(recommended: true, status:'online') }
19
- scope :recent, -> { where(online_date: 5.days.ago.. Time.current) }
19
+ scope :recent, -> { where(online_date: 5.days.ago.. Time.current, status:'online') }
20
20
  scope :online_category, -> (category_id) {where("status='online' AND category_id= ?", category_id)}
21
21
 
22
22
  def video
@@ -0,0 +1,8 @@
1
+ .col-md-7
2
+ %h3 About
3
+ = @project.about.html_safe
4
+ %hr
5
+ %h3 Budget
6
+ = @project.budget.html_safe
7
+ .col-md-4
8
+ = render "hatchy/shared/project", project: @project
@@ -0,0 +1,55 @@
1
+ %table.table.table-condensed.table-striped
2
+ %tr
3
+ %th Owner
4
+ %td= link_to @project.user.full_name, @project.user
5
+ %th Status
6
+ %td
7
+ .dropup
8
+ %button.btn.btn-default.dropdown-toggle{data:{toggle:"dropdown"}}
9
+ = @project.status
10
+ %span.caret
11
+ %ul.dropdown-menu
12
+ %li= link_to "send to approved", send_to_approved_admin_project_path, method: :put
13
+ %li= link_to "push to online", push_to_online_admin_project_path, method: :put
14
+ %li= link_to "send to rejected", send_to_rejected_admin_project_path, method: :put
15
+ %li= link_to "send to draft", send_to_draft_admin_project_path, method: :put
16
+ %li= link_to "push to trash", push_to_trash_admin_project_path, method: :put
17
+ %tr
18
+ %th Name
19
+ %td
20
+ = best_in_place @project, :name, url: admin_project_path
21
+ = link_to @project do
22
+ %i.fa.fa-share-square-o
23
+ %th Category
24
+ %td= link_to @project.category.name, admin_category_path(@project.category)
25
+ %tr
26
+ %th Recommended
27
+ %td= best_in_place @project, :recommended, as: :checkbox, url: admin_project_path
28
+ %th City
29
+ %td= @project.city
30
+ %tr
31
+ %th Video URL
32
+ %td= link_to @project.video_url, @project.video_url
33
+ %th Short URL
34
+ %td= link_to @project.short_url, @project.short_url
35
+ %tr
36
+ %th Online Days
37
+ %td= @project.online_days
38
+ %th Budget
39
+ %td= number_to_currency @project.goal
40
+ - if @project.online?
41
+ %tr
42
+ %th Online Date
43
+ %td= @project.online_date.strftime("%m/%d/%Y - %l:%M%p")
44
+ %th Expires at
45
+ %td= @project.expires_at.strftime("%m/%d/%Y - %l:%M%p")
46
+ -if @project.rejected?
47
+ %tr
48
+ %th Rejected at
49
+ %td= @project.rejected_at.strftime("%m/%d/%Y - %l:%M%p")
50
+ %th
51
+ %td
52
+ - if @project.draft?
53
+ %tr
54
+ %th Send to Draft at
55
+ %td= @project.send_to_draft_at
@@ -0,0 +1,34 @@
1
+ %table.table.table-condensed.table-striped
2
+ %tr
3
+ %th Account Type
4
+ %td= account.account_type
5
+ %th Bank
6
+ %td= link_to account.bank.name, admin_bank_path(account.bank)
7
+ %tr
8
+ %th Owner Name
9
+ %td= account.owner_name
10
+ %th Owner Document
11
+ %td= account.owner_document
12
+ %tr
13
+ %th Email
14
+ %td= account.email
15
+ %th Phone
16
+ %td= account.phone
17
+ %tr
18
+ %th Account
19
+ %td= account.account
20
+ %th Account Digit
21
+ %td= account.account_digit
22
+ %tr
23
+ %th Address State
24
+ %td= account.address_state
25
+ %th Address City
26
+ %td= account.address_city
27
+ %tr
28
+ %th Address Street
29
+ %td= account.address_street
30
+ %th Address Number
31
+ %td= account.address_number
32
+ %tr
33
+ %th Address Zip
34
+ %td= account.address_zip
@@ -0,0 +1,25 @@
1
+ .content-wrapper
2
+ .container-fluid
3
+ .row
4
+ .text-center
5
+ %h1 Projects
6
+ %hr
7
+ .row
8
+ .col-md-12
9
+ = render 'hatchy/admin/shared/admin_navtabs', list_view: admin_projects_path, new_view: ""
10
+ %table.table.table-condensed.table-striped.ajax-data-table{data:{source:admin_projects_url(format: :json)}}
11
+ %thead
12
+ %tr
13
+ %th Id
14
+ %th Recommended
15
+ %th Name
16
+ %th Owner
17
+ %th Category
18
+ %th City
19
+ %th Status
20
+ %th Goal
21
+ %th Draft At
22
+ %th Online Days
23
+ %th Online Date
24
+ %th Expires At
25
+ %tbody
@@ -0,0 +1,22 @@
1
+ .content-wrapper
2
+ .container-fluid
3
+ .row
4
+ .text-center
5
+ %h1= @project.name
6
+ %hr
7
+ .row
8
+ .col-md-12
9
+ %ul.nav.nav-tabs
10
+ %li{class: "#{current_page?(admin_projects_path) ? 'active' : ''}" }
11
+ = link_to admin_projects_path do
12
+ %i.fa.fa-list
13
+ %span Index
14
+ %h3 Basic Info
15
+ = render 'hatchy/admin/projects/basic_info'
16
+ - if @project.account != nil
17
+ %h3 Project Account
18
+ = render 'hatchy/admin/projects/project_account', account: @project.account
19
+ %hr
20
+ = render 'hatchy/admin/projects/about'
21
+ .col-sm-offset-2.col-sm-10
22
+ =link_to "Delete", admin_projects_path, method: :delete, data:{confirm: "Are you sure?"}, class:'btn btn-danger btn-lg'
@@ -0,0 +1,54 @@
1
+ %table.table.table-condensed.table-striped
2
+ %tr
3
+ %th Admin
4
+ %td= check_box "Admin", @user.admin, checked: @user.admin, disabled:true
5
+ %th Email
6
+ %td= @user.email
7
+ %tr
8
+ %th First Name
9
+ %td= @user.first_name
10
+ %th Last Name
11
+ %td= @user.last_name
12
+ %tr
13
+ %th Country
14
+ %td= @user.country.present? ? @user.country.name : "-"
15
+ %th State
16
+ %td= @user.address_state
17
+ %tr
18
+ %th City
19
+ %td= @user.address_city
20
+ %th Zipcode
21
+ %td= @user.address_zip
22
+ %tr
23
+ %th Street
24
+ %td= @user.address_street
25
+ %th Number
26
+ %td= @user.address_number
27
+ %tr
28
+ %th Phone
29
+ %td= @user.phone
30
+ %th Mobile
31
+ %td= @user.mobile
32
+ %tr
33
+ %th Facebook
34
+ %td= @user.facebook_link
35
+ %th Twitter
36
+ %td= @user.twitter_link
37
+ %tr
38
+ %th Created at
39
+ %td= @user.created_at.strftime("%m/%d/%Y - %l:%M%p")
40
+ %th Updated at
41
+ %td= @user.updated_at.strftime("%m/%d/%Y - %l:%M%p")
42
+ %tr
43
+ %th Sign In Count
44
+ %td= @user.sign_in_count
45
+ %tr
46
+ %th Current Sign In at
47
+ %td= @user.current_sign_in_at.strftime("%m/%d/%Y - %l:%M%p")
48
+ %th Last Sign In at
49
+ %td= @user.last_sign_in_at.strftime("%m/%d/%Y - %l:%M%p")
50
+ %tr
51
+ %th Last Sign In Ip
52
+ %td= @user.last_sign_in_ip
53
+ %th Current Sign In Ip
54
+ %td= @user.current_sign_in_ip
@@ -0,0 +1,25 @@
1
+ %table.table.table-condensed.table-striped.data-table
2
+ %thead
3
+ %tr
4
+ %th Project
5
+ %th User
6
+ %th Reward
7
+ %th Anonymous
8
+ %th Document
9
+ %th Ip Address
10
+ %th Card Type
11
+ %th Value
12
+ %th Status
13
+
14
+ %tbody
15
+ - contributions.each do |contribution|
16
+ %tr
17
+ %td= link_to contribution.project.name, admin_projects_path
18
+ %td= link_to contribution.user.full_name, admin_users_path
19
+ %td= link_to contribution.reward.id, "#"
20
+ %td= check_box "Anonymous", contribution.anonymous, checked: contribution.anonymous, disabled:true
21
+ %td= contribution.document
22
+ %td= contribution.ip_address
23
+ %td= contribution.card_type
24
+ %td= number_to_currency contribution.value
25
+ %td= contribution.status
@@ -0,0 +1,31 @@
1
+ %table.table.table-condensed.table-striped.data-table
2
+ %thead
3
+ %tr
4
+ %th Name
5
+ %th Recommended
6
+ %th Category
7
+ %th City
8
+ %th Status
9
+ %th Goal
10
+ %th Draft At
11
+ %th Online Days
12
+ %th Online Date
13
+ %th Expires At
14
+
15
+ %tbody
16
+ - projects.each do |project|
17
+ %tr
18
+ %td= project.name
19
+ %td= check_box "recommended", project.recommended, checked: project.recommended, disabled:true
20
+ %td= link_to project.category.name, admin_category_path(project.category)
21
+ %td= project.city
22
+ %td= project.status
23
+ %td= number_to_currency project.goal
24
+ %td= project.send_to_draft_at.strftime("%m/%d/%Y - %l:%M%p")
25
+ %td= project.online_days
26
+ - if project.online?
27
+ %td= project.online_date.strftime("%m/%d/%Y - %l:%M%p")
28
+ %td= project.expires_at.strftime("%m/%d/%Y - %l:%M%p")
29
+ - else
30
+ %td -
31
+ %td -
@@ -0,0 +1,24 @@
1
+ .content-wrapper
2
+ .container-fluid
3
+ .row
4
+ .text-center
5
+ %h1 Users
6
+ %hr
7
+ .row
8
+ .col-md-12
9
+ = render 'hatchy/admin/shared/admin_navtabs', list_view: admin_users_path, new_view: ""
10
+ %table.table.table-condensed.table-striped.ajax-data-table{data:{source:admin_users_url(format: :json)}}
11
+ %thead
12
+ %tr
13
+ %th Id
14
+ %th Admin
15
+ %th First Name
16
+ %th Last Name
17
+ %th Email
18
+ %th Document
19
+ %th Phone
20
+ %th Mobile
21
+ %th Newsletter
22
+ %th Signin Count
23
+ %th Last Signin At
24
+ %tbody
@@ -0,0 +1,20 @@
1
+ .content-wrapper
2
+ .container-fluid
3
+ .row
4
+ .text-center
5
+ %h1= @user.full_name
6
+ %hr
7
+ .row
8
+ .col-md-12
9
+ = render 'hatchy/admin/shared/admin_navtabs', list_view: admin_users_path, new_view: "", edit_path: edit_admin_user_path
10
+ %h3 Basic Info
11
+ = render 'hatchy/admin/users/basic_info'
12
+ %hr
13
+ %h3 Projects
14
+ = render 'hatchy/admin/users/projects', projects: @user.projects
15
+ %hr
16
+ %h3 Contributions
17
+ = render 'hatchy/admin/users/contributions', contributions: @user.contributions
18
+ %hr
19
+ .col-sm-offset-2.col-sm-10
20
+ =link_to "Delete", admin_user_path(@user), method: :delete, data:{confirm: "Are you sure?"}, class:'btn btn-danger btn-lg'
@@ -0,0 +1,24 @@
1
+ require 'rails/generators'
2
+ module Hatchy::Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ def create_route
7
+ route 'mount Hatchy::Engine => "/"'
8
+ end
9
+
10
+ def copy_initializer
11
+ template "hatchy.rb", "config/initializers/hatchy.rb"
12
+ end
13
+
14
+ def copy_locale
15
+ copy_file "../../../config/locales/en.yml", "config/locales/hatchy.en.yml"
16
+ copy_file "../../../config/locales/devise.en.yml", "config/locales/devise.en.yml"
17
+ end
18
+
19
+ def copy_devise_initializer
20
+ copy_file "../../../config/initializers/devise.rb", "config/initializers/devise.rb"
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,4 @@
1
+ Hatchy.setup do |config|
2
+ # Set Theme
3
+ config.theme = 'default'
4
+ end
@@ -8,6 +8,7 @@ require "video_info"
8
8
  require "pundit"
9
9
  require "kaminari"
10
10
  require "jquery-datatables-rails"
11
+ require "best_in_place"
11
12
  require "hatchy/engine"
12
13
 
13
14
  module Hatchy
@@ -21,4 +22,11 @@ module Hatchy
21
22
 
22
23
  mattr_accessor :theme
23
24
  @@theme = 'default'
25
+
26
+ # Default way to setup Hatchy. Run rails generate hatchy_install to create
27
+ # a fresh initializer with all configuration values.
28
+ def self.setup
29
+ yield self
30
+ end
31
+
24
32
  end
@@ -1,3 +1,3 @@
1
1
  module Hatchy
2
- VERSION = "0.0.5.pre"
2
+ VERSION = "0.0.6.pre"
3
3
  end
@@ -5,14 +5,24 @@ namespace :hatchy do
5
5
  require File.join(Hatchy.root, 'db', 'seed')
6
6
  end
7
7
 
8
- desc "Import default set of countries"
8
+ desc "Import default set of countries"
9
9
  task :import_countries => :environment do
10
10
  Hatchy::CountryImporter.import
11
11
  end
12
12
 
13
+ desc "Create a default admin user"
14
+ task :create_admin_user => :environment do
15
+ Hatchy::User.create(email:'admin@example.com', password:'password', password_confirmation:'password', first_name:'Default', last_name:'Admin', admin: true)
16
+ puts " New user has been created successfully."
17
+ puts
18
+ puts " E-Mail Address..: admin@example.com"
19
+ puts " Password........: password"
20
+ end
21
+
13
22
  desc "Run the setup task for a new application"
14
23
  task :setup => :environment do
15
24
  Rake::Task["hatchy:seed"].invoke
16
25
  Rake::Task["hatchy:import_countries"].invoke if Hatchy::Country.all.empty?
26
+ Rake::Task["hatchy:create_admin_user"].invoke if Hatchy::User.all.empty?
17
27
  end
18
28
  end
@@ -0,0 +1,7 @@
1
+ require 'rails_helper'
2
+
3
+ module Hatchy
4
+ RSpec.describe Admin::ProjectsController, type: :controller do
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'rails_helper'
2
+
3
+ module Hatchy
4
+ RSpec.describe Admin::UsersController, type: :controller do
5
+
6
+ end
7
+ end