hatchy 0.0.5.pre → 0.0.6.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +68 -0
- data/app/assets/javascripts/hatchy/admin.js +7 -0
- data/app/controllers/hatchy/admin/projects_controller.rb +58 -0
- data/app/controllers/hatchy/admin/users_controller.rb +47 -0
- data/app/controllers/hatchy/projects_controller.rb +1 -1
- data/app/controllers/hatchy/users_controller.rb +1 -1
- data/app/datatables/hatchy/contributions_datatable.rb +68 -0
- data/app/datatables/hatchy/projects_datatable.rb +71 -0
- data/app/datatables/hatchy/users_datatable.rb +70 -0
- data/app/models/concerns/hatchy/project_states.rb +4 -5
- data/app/models/hatchy/project.rb +1 -1
- data/app/views/hatchy/admin/projects/_about.html.haml +8 -0
- data/app/views/hatchy/admin/projects/_basic_info.html.haml +55 -0
- data/app/views/hatchy/admin/projects/_project_account.html.haml +34 -0
- data/app/views/hatchy/admin/projects/index.html.haml +25 -0
- data/app/views/hatchy/admin/projects/show.html.haml +22 -0
- data/app/views/hatchy/admin/users/_basic_info.html.haml +54 -0
- data/app/views/hatchy/admin/users/_contributions.html.haml +25 -0
- data/app/views/hatchy/admin/users/_projects.html.haml +31 -0
- data/app/views/hatchy/admin/users/index.html.haml +24 -0
- data/app/views/hatchy/admin/users/show.html.haml +20 -0
- data/lib/generators/hatchy/install_generator.rb +24 -0
- data/lib/generators/templates/hatchy.rb +4 -0
- data/lib/hatchy.rb +8 -0
- data/lib/hatchy/version.rb +1 -1
- data/lib/tasks/hatchy_tasks.rake +11 -1
- data/spec/controllers/hatchy/admin/projects_controller_spec.rb +7 -0
- data/spec/controllers/hatchy/admin/users_controller_spec.rb +7 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/log/development.log +40926 -0
- data/spec/dummy/public/uploads/hatchy/project/project_img/2/Kickstarter-games.jpg +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/69d0e5fd934e4f651c4126e0e7c8994f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7cba22a2cfc1f0a02bf5fa3a0e4e5a27 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8e08251664adb259d48c3ff9019fb9cf +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/adf03687ee42f87002445c1096069d64 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bde5827fcb5ae18fd1ca1c57386417be +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c37311498380e52a91dbfc2c96425eac +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d11f4f73ecc91eb895ed1a2da31f13ba +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d41f33e5d0faf16d0549d1a45aef4f06 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/fb4485de1e413169e29fd17a5549b7d5 +0 -0
- metadata +52 -3
- data/lib/hatchy/setup_generator.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e145ab2442f609b60865ae885df01448a1b4f8ec
|
4
|
+
data.tar.gz: 7bd3a8aec7e366dfa033b38690bdd844dfa43f5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f85d4e07cb8761b8b6b0fcbc36c5a7c261f8ffb14b6aa3a476cd4af4c8d46b9c5338e37609bd88e58dfc4965ae265d7bc19a79791171fb19fc3decf1ff821f5
|
7
|
+
data.tar.gz: 68189b3e839f519eff98091ef5ae48109158e31cc760c6786e4a015fcfcdc53b38a9698a5511f0d1dcb851b641e0e285495e7f6d9629d97525a16638924eff72
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Hatchy - Crowdfunding Platform
|
2
|
+
|
3
|
+
Hatchy, is the first open source Rails engine with Crowdfunding features, such as:
|
4
|
+
* Projects
|
5
|
+
* Project's Admin Interface
|
6
|
+
* Contributions
|
7
|
+
* Rewards
|
8
|
+
* Donations
|
9
|
+
* Profiles
|
10
|
+
* Admin Interface (Inspired by Rails Admin)
|
11
|
+
* Payment Gateways (Paypal, Stripe, etc)
|
12
|
+
* Style and Themes customization based on bootstrap
|
13
|
+
|
14
|
+
## Installing into a new Rails application
|
15
|
+
To get up and running with Hatchy in a new Rails application is simple. Just follow the instructions below.
|
16
|
+
|
17
|
+
rails new my_project
|
18
|
+
cd my_project
|
19
|
+
echo "gem 'hatchy', '0.0.6.pre'" >> Gemfile
|
20
|
+
bundle
|
21
|
+
rails g hatchy:install
|
22
|
+
rake db:migrate hatchy:setup
|
23
|
+
rails server
|
24
|
+
|
25
|
+
## State of the project
|
26
|
+
The project is not production ready yet.
|
27
|
+
Currently working on 0.0.6.pre and the first release
|
28
|
+
|
29
|
+
## Documentation
|
30
|
+
auto-generated by yard
|
31
|
+
|
32
|
+
## Links
|
33
|
+
TO-DO:
|
34
|
+
* Payments Gateway with activemerchant
|
35
|
+
* Admin Projects
|
36
|
+
* Admin Users
|
37
|
+
* Admin Contributions
|
38
|
+
* Project's Posts and comments
|
39
|
+
* Project's admin metrics
|
40
|
+
* Project's Donations
|
41
|
+
* CronJobs for project's states
|
42
|
+
* Demo
|
43
|
+
|
44
|
+
## Contribution
|
45
|
+
If you'd like to help with this project, please get in touch with me. By e-mail to hugomarquez.dev@gmail.com
|
46
|
+
|
47
|
+
## Credits
|
48
|
+
Author: Hugo Márquez
|
49
|
+
|
50
|
+
|
51
|
+
## License
|
52
|
+
Hatchy is licenced under the MIT license. Full details can be found in the MIT-LICENSE file in the root of the repository.
|
53
|
+
|
54
|
+
## Dependencies
|
55
|
+
We do not try to reinvent the wheel, so this is built with open source projects:
|
56
|
+
* for complete list, check out the Gemfile/gemspec
|
57
|
+
|
58
|
+
Tool | Description
|
59
|
+
--------------------- | -----------
|
60
|
+
[CarrierWave] | Simple and extremely flexible way to upload files from Ruby applications.
|
61
|
+
[Devise] | Powerful, extensible user authentication
|
62
|
+
[Ruby] | Open source programming language
|
63
|
+
[Rails] | Open-source web framework
|
64
|
+
|
65
|
+
[CarrierWave]: https://github.com/carrierwaveuploader/carrierwave
|
66
|
+
[Devise]: https://github.com/plataformatec/devise
|
67
|
+
[Ruby]: https://www.ruby-lang.org/en/
|
68
|
+
[Rails]: http://rubyonrails.org/
|
@@ -5,11 +5,13 @@
|
|
5
5
|
//= require 'hatchy/application.js'
|
6
6
|
//= require dataTables/jquery.dataTables
|
7
7
|
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
|
8
|
+
//= require best_in_place
|
8
9
|
|
9
10
|
var admin = (function(){
|
10
11
|
// cache DOM
|
11
12
|
var $ajax_data_table = $('.ajax-data-table');
|
12
13
|
var $data_table = $('.data-table');
|
14
|
+
var $bestInPlace = $('.best_in_place');
|
13
15
|
|
14
16
|
// functions
|
15
17
|
function setAjaxDataTable(){
|
@@ -29,8 +31,13 @@ var admin = (function(){
|
|
29
31
|
});
|
30
32
|
}
|
31
33
|
|
34
|
+
function setBestInPlace(){
|
35
|
+
$bestInPlace.best_in_place();
|
36
|
+
}
|
37
|
+
|
32
38
|
setDataTable();
|
33
39
|
setAjaxDataTable();
|
40
|
+
setBestInPlace();
|
34
41
|
|
35
42
|
return{};
|
36
43
|
})();
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Hatchy
|
2
|
+
class Admin::ProjectsController < Admin::ApplicationController
|
3
|
+
before_action :set_project, only: [:edit, :show, :update, :destroy]
|
4
|
+
|
5
|
+
# GET /projects
|
6
|
+
def index
|
7
|
+
respond_to do |format|
|
8
|
+
format.html
|
9
|
+
format.json { render json: Hatchy::ProjectsDatatable.new(view_context) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /project/:id
|
14
|
+
def show
|
15
|
+
end
|
16
|
+
|
17
|
+
# GET /project/:id/edit
|
18
|
+
def edit
|
19
|
+
end
|
20
|
+
|
21
|
+
# PATCH /project/:id
|
22
|
+
# PUT /project/:id
|
23
|
+
def update
|
24
|
+
respond_to do |format|
|
25
|
+
if @project.update_attributes(project_params)
|
26
|
+
format.html {redirect_to admin_project_path(@project), notice: 'Project was successfully updated.'}
|
27
|
+
format.json {head :ok}
|
28
|
+
else
|
29
|
+
format.html {render :show, flash[:error] = @project.errors.full_messages.to_sentence}
|
30
|
+
format.json {render json: @project.errors.full_messages.to_sentence, status: :unprocessable_entity }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
[:send_to_approved, :push_to_online, :send_to_rejected, :send_to_draft, :push_to_trash].each do |m|
|
36
|
+
define_method m do
|
37
|
+
set_project
|
38
|
+
@project.send("#{m}")
|
39
|
+
if !@project.valid?
|
40
|
+
redirect_to admin_project_path(@project)
|
41
|
+
flash[:error] = @project.errors.full_messages.to_sentence
|
42
|
+
else
|
43
|
+
@project.save
|
44
|
+
redirect_to admin_project_path(@project), notice: "Project was #{m.to_s.humanize}."
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def set_project
|
51
|
+
@project = Hatchy::Project.find(params[:id])
|
52
|
+
end
|
53
|
+
|
54
|
+
def project_params
|
55
|
+
params[:project].permit(:name, :status, :recommended)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Hatchy
|
2
|
+
class Admin::UsersController < Admin::ApplicationController
|
3
|
+
before_action :set_user, only: [:edit, :show, :update, :destroy]
|
4
|
+
|
5
|
+
# GET /users
|
6
|
+
def index
|
7
|
+
respond_to do |format|
|
8
|
+
format.html
|
9
|
+
format.json { render json: Hatchy::UsersDatatable.new(view_context) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /user/:id/edit
|
14
|
+
def edit
|
15
|
+
end
|
16
|
+
|
17
|
+
# GET /user/:id
|
18
|
+
def show
|
19
|
+
end
|
20
|
+
|
21
|
+
# PATCH /user/:id
|
22
|
+
# PUT /user/:id
|
23
|
+
def update
|
24
|
+
if @user.update(user_params)
|
25
|
+
redirect_to admin_user_path(@user), notice: 'User was successfully updated.'
|
26
|
+
else
|
27
|
+
render :edit
|
28
|
+
flash[:error] = @user.errors.full_messages.to_sentence
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# DELETE /user/1
|
33
|
+
def destroy
|
34
|
+
@user.destroy
|
35
|
+
redirect_to admin_users_path, notice: 'User was successfully destroyed.'
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def set_user
|
40
|
+
@user = Hatchy::User.find(params[:id])
|
41
|
+
end
|
42
|
+
|
43
|
+
def user_params
|
44
|
+
params[:user].permit(:first_name, :last_name)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Hatchy
|
2
|
+
class ContributionsDatatable
|
3
|
+
delegate :params, :link_to, :check_box, :number_to_currency, to: :@view
|
4
|
+
|
5
|
+
def initialize(view)
|
6
|
+
@view = view
|
7
|
+
end
|
8
|
+
|
9
|
+
def as_json(options = {})
|
10
|
+
{
|
11
|
+
draw: params[:draw].to_i,
|
12
|
+
recordsTotal: Hatchy::Contribution.count,
|
13
|
+
recordsFiltered: contributions.count,
|
14
|
+
data: data
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def data
|
21
|
+
contributions.map do |contribution|
|
22
|
+
[
|
23
|
+
link_to(contribution.id, "#"),
|
24
|
+
link_to(contribution.project.name, contribution.project),
|
25
|
+
link_to(contribution.user.full_name, "/admin/users/#{contribution.user.id}"),
|
26
|
+
link_to(contribution.reward.id, "#"),
|
27
|
+
check_box("Anonymous", contribution.anonymous, checked: contribution.anonymous, disabled: true),
|
28
|
+
contribution.ip_address,
|
29
|
+
contribution.card_type,
|
30
|
+
number_to_currency(contribution.value),
|
31
|
+
contribution.status
|
32
|
+
]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def contributions
|
37
|
+
@contributions ||= fetch_contributions
|
38
|
+
end
|
39
|
+
|
40
|
+
def fetch_contributions
|
41
|
+
contributions = Hatchy::Contribution.order("#{sort_column} #{sort_direction}")
|
42
|
+
contributions = contributions.page(page).per(per_page)
|
43
|
+
if params[:search][:value].present? && !params[:search][:value].blank?
|
44
|
+
contributions = contributions.where("name like :search or status like :search", search: "%#{params[:search][:value]}%")
|
45
|
+
end
|
46
|
+
contributions
|
47
|
+
end
|
48
|
+
|
49
|
+
def page
|
50
|
+
params[:displayStart].to_i/per_page + 1
|
51
|
+
end
|
52
|
+
|
53
|
+
def per_page
|
54
|
+
params[:pageLength].to_i > 0 ? params[:pageLength].to_i : 10
|
55
|
+
end
|
56
|
+
|
57
|
+
def sort_column
|
58
|
+
columns = %w[id project user reward anonymous ip_address card_type value status]
|
59
|
+
hash = params[:order]
|
60
|
+
columns[hash.flatten[1]["column"].to_i]
|
61
|
+
end
|
62
|
+
|
63
|
+
def sort_direction
|
64
|
+
hash = params[:order]
|
65
|
+
hash.flatten[1]["dir"] == "desc" ? "desc" : "asc"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Hatchy
|
2
|
+
class ProjectsDatatable
|
3
|
+
delegate :params, :h, :link_to, :check_box, :number_to_currency, to: :@view
|
4
|
+
|
5
|
+
def initialize(view)
|
6
|
+
@view = view
|
7
|
+
end
|
8
|
+
|
9
|
+
def as_json(options = {})
|
10
|
+
{
|
11
|
+
draw: params[:draw].to_i,
|
12
|
+
recordsTotal: Hatchy::Project.count,
|
13
|
+
recordsFiltered: projects.count,
|
14
|
+
data: data
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def data
|
21
|
+
projects.map do |project|
|
22
|
+
[
|
23
|
+
link_to(project.id, "/admin/projects/#{project.id}"),
|
24
|
+
check_box("Recommended", project.recommended, checked: project.recommended, disabled: true),
|
25
|
+
link_to(project.name, project),
|
26
|
+
link_to(project.user.full_name, project.user),
|
27
|
+
project.category.name,
|
28
|
+
project.city,
|
29
|
+
project.status,
|
30
|
+
number_to_currency(project.goal),
|
31
|
+
project.send_to_draft_at.strftime("%m/%d/%Y - %l:%M%p"),
|
32
|
+
project.online_days,
|
33
|
+
project.online? ? project.online_date.strftime("%m/%d/%Y - %l:%M%p") : "-",
|
34
|
+
project.online? ? project.expires_at.strftime("%m/%d/%Y - %l:%M%p") : "-",
|
35
|
+
]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def projects
|
40
|
+
@projects ||= fetch_projects
|
41
|
+
end
|
42
|
+
|
43
|
+
def fetch_projects
|
44
|
+
projects = Hatchy::Project.order("#{sort_column} #{sort_direction}")
|
45
|
+
projects = projects.page(page).per(per_page)
|
46
|
+
if params[:search][:value].present? && !params[:search][:value].blank?
|
47
|
+
projects = projects.where("name like :search", search: "%#{params[:search][:value]}%")
|
48
|
+
end
|
49
|
+
projects
|
50
|
+
end
|
51
|
+
|
52
|
+
def page
|
53
|
+
params[:displayStart].to_i/per_page + 1
|
54
|
+
end
|
55
|
+
|
56
|
+
def per_page
|
57
|
+
params[:pageLength].to_i > 0 ? params[:pageLength].to_i : 10
|
58
|
+
end
|
59
|
+
|
60
|
+
def sort_column
|
61
|
+
columns = %w[id name city goal online_days online_date expires_at send_to_draft_at status recommended]
|
62
|
+
hash = params[:order]
|
63
|
+
columns[hash.flatten[1]["column"].to_i]
|
64
|
+
end
|
65
|
+
|
66
|
+
def sort_direction
|
67
|
+
hash = params[:order]
|
68
|
+
hash.flatten[1]["dir"] == "desc" ? "desc" : "asc"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Hatchy
|
2
|
+
class UsersDatatable
|
3
|
+
delegate :params, :h, :link_to, :check_box, :number_to_currency, to: :@view
|
4
|
+
|
5
|
+
def initialize(view)
|
6
|
+
@view = view
|
7
|
+
end
|
8
|
+
|
9
|
+
def as_json(options = {})
|
10
|
+
{
|
11
|
+
draw: params[:draw].to_i,
|
12
|
+
recordsTotal: Hatchy::User.count,
|
13
|
+
recordsFiltered: users.count,
|
14
|
+
data: data
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def data
|
21
|
+
users.map do |user|
|
22
|
+
[
|
23
|
+
link_to(user.id, "/admin/users/#{user.id}"),
|
24
|
+
check_box("admin", user.admin, checked: user.admin, disabled: true),
|
25
|
+
user.first_name,
|
26
|
+
user.last_name,
|
27
|
+
link_to(user.email, user),
|
28
|
+
user.document,
|
29
|
+
user.phone,
|
30
|
+
user.mobile,
|
31
|
+
check_box("newsletter", user.newsletter, checked: user.newsletter, disabled: true),
|
32
|
+
user.sign_in_count,
|
33
|
+
user.last_sign_in_at.strftime("%m/%d/%Y - %l:%M%p"),
|
34
|
+
]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def users
|
39
|
+
@users ||= fetch_users
|
40
|
+
end
|
41
|
+
|
42
|
+
def fetch_users
|
43
|
+
users = Hatchy::User.order("#{sort_column} #{sort_direction}")
|
44
|
+
users = users.page(page).per(per_page)
|
45
|
+
if params[:search][:value].present? && !params[:search][:value].blank?
|
46
|
+
users = users.where("email like :search", search: "%#{params[:search][:value]}%")
|
47
|
+
end
|
48
|
+
users
|
49
|
+
end
|
50
|
+
|
51
|
+
def page
|
52
|
+
params[:displayStart].to_i/per_page + 1
|
53
|
+
end
|
54
|
+
|
55
|
+
def per_page
|
56
|
+
params[:pageLength].to_i > 0 ? params[:pageLength].to_i : 10
|
57
|
+
end
|
58
|
+
|
59
|
+
def sort_column
|
60
|
+
columns = %w[id admin first_name last_name email document phone mobile newsletter sign_in_count last_sign_in_at]
|
61
|
+
hash = params[:order]
|
62
|
+
columns[hash.flatten[1]["column"].to_i]
|
63
|
+
end
|
64
|
+
|
65
|
+
def sort_direction
|
66
|
+
hash = params[:order]
|
67
|
+
hash.flatten[1]["dir"] == "desc" ? "desc" : "asc"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|