dune-admin 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/.travis.yml +18 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +74 -0
- data/Rakefile +14 -0
- data/app/assets/images/dune/admin/.gitkip +0 -0
- data/app/assets/javascripts/dune-admin.js +2 -0
- data/app/assets/javascripts/dune/admin/admin.js.coffee +11 -0
- data/app/assets/javascripts/dune/admin/channels/new.js.coffee +14 -0
- data/app/assets/javascripts/dune/admin/modules/sort.js.coffee +44 -0
- data/app/assets/stylesheets/dune/admin/.gitkip +0 -0
- data/app/assets/stylesheets/dune/admin/admin.sass +37 -0
- data/app/assets/stylesheets/neighborly-admin.sass +1 -0
- data/app/controllers/dune/admin/base_controller.rb +25 -0
- data/app/controllers/dune/admin/channels/members_controller.rb +46 -0
- data/app/controllers/dune/admin/channels_controller.rb +49 -0
- data/app/controllers/dune/admin/contacts_controller.rb +9 -0
- data/app/controllers/dune/admin/contributions_controller.rb +33 -0
- data/app/controllers/dune/admin/dashboard_controller.rb +8 -0
- data/app/controllers/dune/admin/financials_controller.rb +33 -0
- data/app/controllers/dune/admin/press_assets_controller.rb +26 -0
- data/app/controllers/dune/admin/projects_controller.rb +80 -0
- data/app/controllers/dune/admin/reports/base_controller.rb +8 -0
- data/app/controllers/dune/admin/reports/contribution_reports_controller.rb +8 -0
- data/app/controllers/dune/admin/reports/funding_raised_per_project_reports_controller.rb +4 -0
- data/app/controllers/dune/admin/reports/statistics_controller.rb +5 -0
- data/app/controllers/dune/admin/tags_controller.rb +35 -0
- data/app/controllers/dune/admin/users_controller.rb +27 -0
- data/app/models/dune/admin/.gitkip +0 -0
- data/app/models/dune/admin/contribution_concern.rb +23 -0
- data/app/models/dune/admin/funding_raised_per_project_report.rb +5 -0
- data/app/models/dune/admin/project_concern.rb +41 -0
- data/app/models/dune/admin/statistics.rb +5 -0
- data/app/models/dune/admin/user_concern.rb +13 -0
- data/app/policies/dune/admin/admin_policy.rb +7 -0
- data/app/views/dune/admin/.gitkip +0 -0
- data/app/views/dune/admin/channels/_form.html.slim +98 -0
- data/app/views/dune/admin/channels/edit.html.slim +7 -0
- data/app/views/dune/admin/channels/index.html.slim +58 -0
- data/app/views/dune/admin/channels/members/index.html.slim +38 -0
- data/app/views/dune/admin/channels/members/new.html.slim +11 -0
- data/app/views/dune/admin/channels/new.html.slim +7 -0
- data/app/views/dune/admin/contacts/index.html.slim +32 -0
- data/app/views/dune/admin/contacts/show.html.slim +34 -0
- data/app/views/dune/admin/contributions/index.html.slim +138 -0
- data/app/views/dune/admin/dashboard/index.html.slim +65 -0
- data/app/views/dune/admin/financials/index.html.slim +88 -0
- data/app/views/dune/admin/layouts/_menu.html.slim +11 -0
- data/app/views/dune/admin/press_assets/_form.html.slim +11 -0
- data/app/views/dune/admin/press_assets/edit.html.slim +9 -0
- data/app/views/dune/admin/press_assets/index.html.slim +32 -0
- data/app/views/dune/admin/press_assets/new.html.slim +9 -0
- data/app/views/dune/admin/projects/index.html.slim +151 -0
- data/app/views/dune/admin/projects/populate_contribution.html.slim +48 -0
- data/app/views/dune/admin/tags/_form.html.slim +4 -0
- data/app/views/dune/admin/tags/edit.html.slim +7 -0
- data/app/views/dune/admin/tags/index.html.slim +44 -0
- data/app/views/dune/admin/tags/new.html.slim +7 -0
- data/app/views/dune/admin/users/index.html.slim +68 -0
- data/bin/rails +8 -0
- data/config/locales/en.yml +274 -0
- data/config/routes.rb +47 -0
- data/db/migrate/20141005184741_create_dune_admin_funding_raised_per_project_reports.rb +21 -0
- data/db/migrate/20141005191509_create_dune_admin_statistics.rb +55 -0
- data/dune-admin.gemspec +27 -0
- data/lib/dune/admin.rb +10 -0
- data/lib/dune/admin/engine.rb +13 -0
- data/lib/dune/admin/version.rb +5 -0
- data/spec/controllers/dune/admin/channels/members_controller_spec.rb +119 -0
- data/spec/controllers/dune/admin/channels_controller_spec.rb +161 -0
- data/spec/controllers/dune/admin/contacts_controller_spec.rb +23 -0
- data/spec/controllers/dune/admin/cotributions_controller_spec.rb +130 -0
- data/spec/controllers/dune/admin/dasboard_controller_spec.rb +18 -0
- data/spec/controllers/dune/admin/financials_controller_spec.rb +45 -0
- data/spec/controllers/dune/admin/press_assets_controller_spec.rb +138 -0
- data/spec/controllers/dune/admin/projects_controller_spec.rb +201 -0
- data/spec/controllers/dune/admin/tags_controller_spec.rb +137 -0
- data/spec/controllers/dune/admin/users_controller_spec.rb +30 -0
- data/spec/models/dune/admin/contribution_concern_spec.rb +19 -0
- data/spec/models/dune/admin/project_concern_spec.rb +56 -0
- data/spec/models/dune/admin/user_concern_spec.rb +65 -0
- data/spec/policies/dune/admin/admin_policy_spec.rb +22 -0
- data/spec/spec_helper.rb +40 -0
- metadata +237 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e5a76f9696d4542e0776c2a528caa988cef4d5da
|
4
|
+
data.tar.gz: 2ca44b916c3f3df91941160f3edd6ccb4d6adfaa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 193c5e8aa177d5c2313723bf97d866a121933f009f85c4687028115c18bd183b3fa5504b241238c13f40688a162781ecc0550fe9ff85707f52703775ba3ca82d
|
7
|
+
data.tar.gz: f8af71a5c49c3ba5c94cf96f0c9ee104845c1153064a58b09c2d45f75d03bd623dd7f58d4f70eb23bf963824e1ad21d7893fbd73a7cd97b015e51c3daac92a3f
|
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
rvm:
|
2
|
+
- 2.1.5
|
3
|
+
|
4
|
+
before_install: gem update --remote bundler
|
5
|
+
|
6
|
+
before_script:
|
7
|
+
- 'git submodule init'
|
8
|
+
- 'git submodule update'
|
9
|
+
- 'cd spec/dummy/'
|
10
|
+
- 'cp .env.example ../../.env'
|
11
|
+
- './bin/bootstrap'
|
12
|
+
- 'bundle exec rake db:migrate'
|
13
|
+
- 'cd ../../'
|
14
|
+
|
15
|
+
script:
|
16
|
+
- 'bundle exec rake spec'
|
17
|
+
notifications:
|
18
|
+
webhooks: https://ci.neighbor.ly/projects/356bc47e-0510-4049-8900-741bf9eda015/status
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemfile_url = File.join(File.dirname(__FILE__), 'spec/dummy/Gemfile')
|
4
|
+
gemfile_content = File.open(gemfile_url, 'rb') { |f| f.read }
|
5
|
+
|
6
|
+
gemspec_gems = %w(
|
7
|
+
dune-admin'
|
8
|
+
spring'
|
9
|
+
)
|
10
|
+
eval_gemfile gemfile_url, (gemfile_content.split("\n").reject do |line|
|
11
|
+
line.empty? || Regexp.union(*gemspec_gems).match(line)
|
12
|
+
end.join("\n"))
|
13
|
+
|
14
|
+
gemspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Neighbor.ly
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Dune::Admin
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
## What
|
6
|
+
|
7
|
+
This is the admin of [Dune](https://github.com/FromUte/dune), a Civic Crowdfunding platform.
|
8
|
+
Originally create by neighborly developper
|
9
|
+
|
10
|
+
## How
|
11
|
+
|
12
|
+
Include this gem as dependency of your project, adding the following line in your `Gemfile`.
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
# Gemfile
|
16
|
+
gem 'neighborly-admin'
|
17
|
+
```
|
18
|
+
|
19
|
+
And install the migrations:
|
20
|
+
|
21
|
+
```
|
22
|
+
$ bundle exec rake railties:install:migrations db:migrate
|
23
|
+
```
|
24
|
+
|
25
|
+
Dune::Admin is a Rails Engine, integrating with your (Dune) Rails application with very little of effort. To turn the engine on, mount it in an appropriate route:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# config/routes.rb
|
29
|
+
mount Dune::Admin::Engine => '/admin/', as: :dune_admin
|
30
|
+
```
|
31
|
+
And load our JavaScript:
|
32
|
+
|
33
|
+
```
|
34
|
+
//= require dune-admin
|
35
|
+
```
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create new Pull Request
|
44
|
+
|
45
|
+
### Running specs
|
46
|
+
|
47
|
+
We prize for our test suite and coverage, so it would be great if you could run the specs to ensure that your patch is not breaking the existing codebase.
|
48
|
+
|
49
|
+
When running specs for the first time, you'll need to download Dune's source code to be tested against your version of the gem. The following command will install the dummy app in `spec/dummy`.
|
50
|
+
|
51
|
+
```
|
52
|
+
$ git submodule init
|
53
|
+
$ git submodule update
|
54
|
+
```
|
55
|
+
|
56
|
+
And before you go, you need to initialize a database for this "dummy" app.
|
57
|
+
|
58
|
+
```
|
59
|
+
$ cd spec/dummy
|
60
|
+
$ cp config/database.sample.yml config/database.yml
|
61
|
+
$ bundle install
|
62
|
+
$ RAILS_ENV=test rake db:create db:migrate
|
63
|
+
$ cd ../../
|
64
|
+
```
|
65
|
+
|
66
|
+
To run the specs just run:
|
67
|
+
|
68
|
+
```
|
69
|
+
$ bundle exec rake spec
|
70
|
+
```
|
71
|
+
|
72
|
+
## License
|
73
|
+
|
74
|
+
Licensed under the [MIT license](LICENSE.txt).
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler"
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
Bundler.setup
|
5
|
+
Bundler::GemHelper.install_tasks
|
6
|
+
|
7
|
+
require "rake"
|
8
|
+
require "rspec/core/rake_task"
|
9
|
+
|
10
|
+
desc "Run all examples"
|
11
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
12
|
+
t.ruby_opts = %w[-w]
|
13
|
+
t.pattern = Dir['spec/**/*_spec.rb'].reject { |f| f.match /spec\/dummy\/*/ }
|
14
|
+
end
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Dune.Dune ?= {}
|
2
|
+
Dune.Dune.Admin ?= {}
|
3
|
+
Dune.Dune.Admin.Channels ?= {}
|
4
|
+
|
5
|
+
Dune.Dune.Admin.Channels.New =
|
6
|
+
init: Backbone.View.extend
|
7
|
+
el: '.admin'
|
8
|
+
|
9
|
+
initialize: ->
|
10
|
+
this.$('.markdown-editor').markItUp(Dune.markdownSettings)
|
11
|
+
|
12
|
+
|
13
|
+
Dune.Dune.Admin.Channels.Edit =
|
14
|
+
modules: -> [Dune.Dune.Admin.Channels.New]
|
@@ -0,0 +1,44 @@
|
|
1
|
+
Dune.Dune ?= {}
|
2
|
+
Dune.Dune.Admin ?= {}
|
3
|
+
Dune.Dune.Admin.Modules ?= {}
|
4
|
+
|
5
|
+
Dune.Dune.Admin.Modules.Sort = Backbone.View.extend
|
6
|
+
el: ".admin"
|
7
|
+
|
8
|
+
events:
|
9
|
+
"click [data-sort]": "sort"
|
10
|
+
|
11
|
+
initialize: ->
|
12
|
+
@form = @$("form")
|
13
|
+
@table = @$(".data-table")
|
14
|
+
@selectSorting() if @table.length > 1
|
15
|
+
|
16
|
+
getSorting: ->
|
17
|
+
sortField = @form.find("[name=order_by]")
|
18
|
+
sort = sortField.val().split(" ")
|
19
|
+
field: sort[0]
|
20
|
+
order: sort[1]
|
21
|
+
|
22
|
+
selectSorting: ->
|
23
|
+
link = @$("a[data-sort=\"" + @getSorting().field + "\"]")
|
24
|
+
sortOrder = link.siblings("span.sort-order")
|
25
|
+
|
26
|
+
# Clean old sort orders
|
27
|
+
@$("[data-sort]").siblings("span.sort-order").html ""
|
28
|
+
|
29
|
+
# Add sorting order to header
|
30
|
+
if @getSorting().order is "DESC"
|
31
|
+
sortOrder.html "(desc)"
|
32
|
+
else
|
33
|
+
sortOrder.html "(asc)"
|
34
|
+
|
35
|
+
sort: (event) ->
|
36
|
+
link = $(event.target)
|
37
|
+
sortField = @form.find("[name=order_by]")
|
38
|
+
|
39
|
+
# Put sorting data in hidden field and select sorting
|
40
|
+
sortField.val link.data("sort") + " " + ((if @getSorting().order is "ASC" then "DESC" else "ASC"))
|
41
|
+
@selectSorting()
|
42
|
+
@form.submit()
|
43
|
+
false
|
44
|
+
|
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
.admin
|
2
|
+
margin-top: +emCalc(50px)
|
3
|
+
margin-bottom: +emCalc(50px)
|
4
|
+
|
5
|
+
section.content
|
6
|
+
padding-top: +emCalc(25px)
|
7
|
+
padding-bottom: +emCalc(25px)
|
8
|
+
@extend .white
|
9
|
+
|
10
|
+
.box
|
11
|
+
margin: +emCalc(15px)
|
12
|
+
min-height: +emCalc(170px)
|
13
|
+
border: 1px solid $border-color
|
14
|
+
border-top: 5px solid $primary-color
|
15
|
+
.title
|
16
|
+
height: +emCalc(30px)
|
17
|
+
background: $border-color
|
18
|
+
border-bottom: 1px solid $border-color
|
19
|
+
font-weight: bold
|
20
|
+
padding-top: 10px
|
21
|
+
.title, p, .hint
|
22
|
+
padding: 5px
|
23
|
+
text-align: center
|
24
|
+
p
|
25
|
+
font-size: 400%
|
26
|
+
margin-bottom: 0
|
27
|
+
font-weight: bold
|
28
|
+
.hint
|
29
|
+
font-size: 80%
|
30
|
+
color: $secondary-color
|
31
|
+
|
32
|
+
table
|
33
|
+
width: 100%
|
34
|
+
margin-top: +emCalc(15px)
|
35
|
+
&.small
|
36
|
+
font-size: 90%
|
37
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "dune/admin/admin"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Dune::Admin
|
2
|
+
def self.policy_class
|
3
|
+
AdminPolicy
|
4
|
+
end
|
5
|
+
|
6
|
+
class BaseController < ::ApplicationController
|
7
|
+
skip_before_filter :set_persistent_warning
|
8
|
+
inherit_resources
|
9
|
+
|
10
|
+
before_filter do
|
11
|
+
authorize Dune::Admin, :access?
|
12
|
+
end
|
13
|
+
|
14
|
+
def update
|
15
|
+
update! do |format|
|
16
|
+
if resource.errors.empty?
|
17
|
+
format.json { respond_with_bip(resource) }
|
18
|
+
else
|
19
|
+
format.html { render action: 'edit' }
|
20
|
+
format.json { respond_with_bip(resource) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Dune::Admin
|
2
|
+
class Channels::MembersController < BaseController
|
3
|
+
actions :index
|
4
|
+
helper_method :parent
|
5
|
+
|
6
|
+
def new; end
|
7
|
+
|
8
|
+
def create
|
9
|
+
if params[:user_id].present?
|
10
|
+
user = User.find(params[:user_id]) rescue nil
|
11
|
+
|
12
|
+
if user.present?
|
13
|
+
if parent.members.include?(user)
|
14
|
+
flash.alert = t('dune.admin.channels.members.messages.already_a_member')
|
15
|
+
else
|
16
|
+
parent.members << user
|
17
|
+
parent.save
|
18
|
+
flash.notice = t('dune.admin.channels.members.messages.success')
|
19
|
+
end
|
20
|
+
else
|
21
|
+
flash.alert = t('dune.admin.channels.members.messages.user_not_found')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
redirect_to channel_members_path(parent)
|
26
|
+
end
|
27
|
+
|
28
|
+
def destroy
|
29
|
+
parent.channel_members.where(user_id: resource.id).first.delete rescue false
|
30
|
+
redirect_to channel_members_path(parent), flash: { success: t('dune.admin.channels.members.messages.removed') }
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
def resource
|
35
|
+
@member ||= parent.members.find(params[:id])
|
36
|
+
end
|
37
|
+
|
38
|
+
def parent
|
39
|
+
@channel ||= Channel.find_by_permalink params[:channel_id]
|
40
|
+
end
|
41
|
+
|
42
|
+
def collection
|
43
|
+
@members ||= parent.members.page(params[:page])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Dune::Admin
|
2
|
+
class ChannelsController < BaseController
|
3
|
+
defaults finder: :find_by_permalink
|
4
|
+
actions :all, except: [:show]
|
5
|
+
|
6
|
+
def create
|
7
|
+
create! { channels_path }
|
8
|
+
end
|
9
|
+
|
10
|
+
def update
|
11
|
+
update! { channels_path }
|
12
|
+
end
|
13
|
+
|
14
|
+
def destroy
|
15
|
+
destroy! { channels_path }
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.channel_actions
|
19
|
+
%w[push_to_draft push_to_online].each do |action|
|
20
|
+
define_method action do
|
21
|
+
resource.send(action)
|
22
|
+
flash.notice = I18n.t("dune.admin.channels.messages.successful.#{action}")
|
23
|
+
redirect_to channels_path(params[:local_params])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
channel_actions
|
28
|
+
|
29
|
+
protected
|
30
|
+
def collection
|
31
|
+
@channels = apply_scopes(end_of_association_chain).order(:name).page(params[:page])
|
32
|
+
end
|
33
|
+
|
34
|
+
def permitted_params
|
35
|
+
user_attrs = [user_attributes: User.attribute_names.map(&:to_sym)]
|
36
|
+
aditional_attrs = [start_content: params.try(:[], :channel).
|
37
|
+
try(:[], :start_content).
|
38
|
+
try(:keys),
|
39
|
+
|
40
|
+
success_content: params.try(:[], :channel).
|
41
|
+
try(:[], :success_content).
|
42
|
+
try(:keys),]
|
43
|
+
params.permit({ channel:
|
44
|
+
Channel.attribute_names.map(&:to_sym) +
|
45
|
+
user_attrs +
|
46
|
+
aditional_attrs })
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|