voluntary 0.0.3 → 0.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/README.rdoc +37 -2
  2. data/app/assets/images/voluntary/spinner.gif +0 -0
  3. data/app/assets/javascripts/voluntary/application.js +2 -2
  4. data/app/assets/javascripts/voluntary/base.js.coffee +8 -1
  5. data/app/assets/javascripts/voluntary/users.js.coffee +2 -3
  6. data/app/assets/stylesheets/voluntary/application.css +2 -0
  7. data/app/assets/stylesheets/voluntary/base.css.sass +62 -0
  8. data/app/assets/stylesheets/voluntary/bootstrap_and_overrides.css.sass +4 -0
  9. data/app/controllers/workflow/project_owner_controller.rb +1 -1
  10. data/app/helpers/collection_helper.rb +5 -1
  11. data/app/helpers/form_helper.rb +6 -2
  12. data/{lib/generators/voluntary/install/templates/app → app}/models/ability.rb +0 -0
  13. data/app/models/page.rb +2 -2
  14. data/app/models/product.rb +9 -9
  15. data/app/models/project.rb +8 -1
  16. data/app/models/task.rb +2 -14
  17. data/app/presenters/shared/collection/table_presenter.rb +2 -2
  18. data/app/views/general/wizard.html.erb +1 -1
  19. data/app/views/layouts/application.html.erb +6 -0
  20. data/app/views/layouts/shared/_navigation.html.erb +4 -1
  21. data/app/views/vacancies/show.html.erb +0 -2
  22. data/db/migrate/20121122185954_add_klass_name_to_products.rb +17 -0
  23. data/lib/applicat/mvc/controller.rb +0 -2
  24. data/lib/applicat/mvc/controller/resource.rb +1 -1
  25. data/lib/applicat/mvc/model/resource/base.rb +8 -3
  26. data/lib/db_seed.rb +1 -1
  27. data/lib/generators/voluntary/install/install_generator.rb +1 -2
  28. data/lib/generators/voluntary/install/templates/app/controllers/application_controller.rb +4 -0
  29. data/lib/generators/voluntary/install/templates/app/models/application/ability.rb +8 -0
  30. data/lib/generators/voluntary/install/templates/config/deploy.rb +2 -0
  31. data/lib/generators/voluntary/install/templates/features/step_definitions/user_steps.rb +4 -0
  32. data/lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb +2 -2
  33. data/lib/generators/voluntary/product_dummy/product_dummy_generator.rb +1 -1
  34. data/lib/generators/voluntary/product_dummy/templates/vendor/assets/javascripts/jquery.tokeninput.js +915 -0
  35. data/lib/generators/voluntary/product_dummy/templates/vendor/assets/stylesheets/token-input-facebook.css +122 -0
  36. data/lib/generators/voluntary/product_dummy/templates/vendor/assets/stylesheets/token-input-mac.css +204 -0
  37. data/lib/generators/voluntary/product_dummy/templates/vendor/assets/stylesheets/token-input.css +127 -0
  38. data/lib/volontariat_seed.rb +27 -0
  39. data/lib/voluntary.rb +6 -5
  40. data/lib/voluntary/version.rb +1 -1
  41. metadata +560 -209
  42. data/app/assets/javascripts/voluntary/bootstrap.js.coffee +0 -4
  43. data/app/assets/stylesheets/voluntary/base.css.scss +0 -40
  44. data/app/assets/stylesheets/voluntary/bootstrap_and_overrides.css.less +0 -67
  45. data/config/initializers/recaptcha.rb +0 -7
@@ -6,6 +6,8 @@ Then you can add existing voluntary products like text creation or create your o
6
6
 
7
7
  == Installation
8
8
 
9
+ === New Application
10
+
9
11
  Run this in your console:
10
12
 
11
13
  rvm --create use 1.9.3@your_crowdsourcing_platform_name
@@ -18,6 +20,8 @@ Add this to your Gemfile:
18
20
 
19
21
  gem 'voluntary'
20
22
 
23
+ Add voluntary products to your Gemfile.
24
+
21
25
  Run this in your console:
22
26
 
23
27
  bundle install
@@ -25,16 +29,24 @@ Run this in your console:
25
29
  Run this in your console (confirm all overwrite questions):
26
30
 
27
31
  rails g voluntary:install
28
- rake voluntary:install:migrations
32
+ rake railties:install:migrations
29
33
 
30
34
  Remove gem 'sqlite3' from your Gemfile.
31
35
 
32
36
  Copy the content of config/database.example.yml into config/database.yml
33
37
 
38
+ Add this to your application.rb:
39
+
40
+ config.generators do |g|
41
+ g.orm :active_record
42
+ end
43
+
34
44
  Remove public/index.html
35
45
 
36
46
  Add at least 1 controller with 1 action, 1 view and a root route.
37
47
 
48
+ Add a Capfile to your Rails root.
49
+
38
50
  Run this in your console:
39
51
 
40
52
  bundle install
@@ -43,6 +55,29 @@ Run this in your console:
43
55
  rake db:seed
44
56
  rails s
45
57
 
58
+ === New Product
59
+
60
+ git clone https://github.com/user/voluntary_product_name.git
61
+ cd voluntary_product_name
62
+ rvm --create use --rvmrc 1.9.3@voluntary_product_name
63
+ gem update bundler
64
+ gem install rails --no-ri --no-rdoc
65
+ cd ..
66
+ rails plugin new voluntary_music_research --database=postgresql --skip-javascript --skip-test-unit --dummy-path=dummy --full
67
+ cd voluntary_product_name
68
+ # Add voluntary gem as a dependency to gemspec.
69
+ # Add development dependencies to gemspec, see voluntary_text_creation.
70
+ bundle install
71
+ cd dummy
72
+ rails g voluntary:product_dummy # confirm all overwrite questions
73
+ # Add "gemspec path: File.expand_path(File.dirname(__FILE__) + '/../')" to the top of the dummy's Gemfile
74
+ bundle install # if it hangs at Fetching source index stop it and deactivate gems until it works and add them back one by one
75
+ >> migrations of voluntary and voluntary_* gems <<
76
+ # database.yml erstellen
77
+ # optional: bundle exec rake db:migrate
78
+ # add "require 'voluntary'" to ../lib/voluntary_product_name.rb
79
+ bundle exec rails s
80
+
46
81
  = License
47
82
 
48
- This project uses MIT-LICENSE.
83
+ This project uses MIT-LICENSE.
@@ -1,6 +1,6 @@
1
1
  //= require jquery
2
- //= require jquery.ui.all
3
2
  //= require jquery_ujs
4
- //= require jquery.tokeninput
5
3
  //= require twitter/bootstrap
4
+ //= require jquery-ui-bootstrap
5
+ //= require jquery.tokeninput
6
6
  //= require_tree .
@@ -1,4 +1,8 @@
1
1
  $(document).ready ->
2
+ $("a[rel=popover]").popover()
3
+ $(".tooltip").tooltip()
4
+ $("a[rel=tooltip]").tooltip()
5
+
2
6
  $( '.accordions' ).each (k, v) ->
3
7
  $(v).accordion({ autoHeight: false });
4
8
 
@@ -31,4 +35,7 @@ $(document).ready ->
31
35
  $($(this).attr('id_element')).val(ui.item.id)
32
36
 
33
37
  return false;
34
- });
38
+ });
39
+
40
+ $( ".datepicker" ).each (k, v) ->
41
+ $(v).datepicker({ dateFormat: "yy-mm-dd", changeYear: true, yearRange: "c-100:c+10" });
@@ -2,11 +2,10 @@
2
2
  # All this logic will automatically be available in application.js.
3
3
  # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
4
4
  jQuery ->
5
- $('#user_area_tokens').tokenInput '/areas.json'
5
+ $('#user_area_tokens').tokenInput '/areas.json',
6
6
  theme: 'facebook'
7
7
  prePopulate: $('#user_area_tokens').data('load')
8
8
 
9
- jQuery ->
10
- $('#user_foreign_language_tokens').tokenInput '/users/languages.json'
9
+ $('#user_foreign_language_tokens').tokenInput '/users/languages.json',
11
10
  theme: 'facebook'
12
11
  prePopulate: $('#user_foreign_language_tokens').data('load')
@@ -10,6 +10,8 @@
10
10
  *
11
11
  *= require_self
12
12
  *= require token-input-facebook
13
+ *= require twitter/bootstrap
14
+ *= require jquery-ui-bootstrap
13
15
  *= require 'voluntary/bootstrap_and_overrides'
14
16
  *= require 'voluntary/base'
15
17
  */
@@ -0,0 +1,62 @@
1
+ body
2
+ padding-top: 60px
3
+
4
+ #plattform_brand
5
+ padding: 10px 0px 10px 0px
6
+ margin-left: 0px
7
+
8
+ #product_brand
9
+ margin-left: 0px
10
+ padding: 10px 15px 10px 5px
11
+
12
+ pre
13
+ background-color: white
14
+ border: 0px
15
+ border-radius: 0px
16
+ display: block
17
+ font-size: 10px
18
+ line-height: 18px
19
+ margin: 0px
20
+ padding: 0px
21
+ white-space: pre-wrap
22
+ word-wrap: break-word
23
+
24
+ code, pre
25
+ font-family: Arial
26
+
27
+ code
28
+ border-radius: 0px
29
+ border-width: 0px
30
+ color: black
31
+ background-color: white
32
+ font-size: 10px
33
+ padding: 0px
34
+
35
+ .auto_width
36
+ width: auto
37
+
38
+ .ui-widget
39
+ font-family: Arial
40
+ font-size: 10px
41
+
42
+ html, body, div, span
43
+ font-family: Arial
44
+ font-size: 10px
45
+
46
+ .nav a
47
+ font-family: Arial
48
+ font-size: 10px
49
+
50
+ .nested_comments
51
+ margin-left: 30px
52
+
53
+ .nested_comments .nested_comments .nested_comments .nested_comments
54
+ margin-left: 0
55
+
56
+ .footer
57
+ margin-top: 20px
58
+
59
+ .floating_form fieldset .control-group
60
+ float: left
61
+ margin-right: 10px
62
+ margin-bottom: 0px
@@ -0,0 +1,4 @@
1
+ @import "twitter/bootstrap/responsive"
2
+
3
+ .nav a
4
+ font-size: 14px !important
@@ -19,7 +19,7 @@ class Workflow::ProjectOwnerController < ApplicationController
19
19
  end
20
20
  end
21
21
 
22
- { stories: [:completed], tasks: [:under_supervision] }.each do |controller, states|
22
+ { stories: [:completed, :active], tasks: [:under_supervision] }.each do |controller, states|
23
23
  states.each do |state|
24
24
  collection = controller.to_s.classify.constantize.where(
25
25
  offeror_id: current_user.id, state: state
@@ -13,7 +13,11 @@ module CollectionHelper
13
13
  value = '-'
14
14
  end
15
15
 
16
- link_to value, eval("#{root_model_class_name(resource).tableize.singularize}_path(resource)")
16
+ begin
17
+ link_to value, eval("#{root_model_class_name(resource).tableize.singularize}_path(resource)")
18
+ rescue
19
+ link_to value, eval("#{root_model_class_name(resource).constantize.table_name.singularize}_path(resource)")
20
+ end
17
21
  elsif column.match('_id')
18
22
  association = nil
19
23
 
@@ -33,7 +33,11 @@ module FormHelper
33
33
  end
34
34
  end
35
35
 
36
- def autocomplete_input(f, field)
37
- f.input "#{field}_name", input_html: { data: {autocomplete: eval("autocomplete_#{field.to_s.tableize}_path")} }
36
+ def autocomplete_input(f, field, namespace = nil)
37
+ if namespace
38
+ f.input "#{field}_name", input_html: { data: {autocomplete: eval("autocomplete_#{namespace}_#{field.to_s.tableize}_path")} }
39
+ else
40
+ f.input "#{field}_name", input_html: { data: {autocomplete: eval("autocomplete_#{field.to_s.tableize}_path")} }
41
+ end
38
42
  end
39
43
  end
@@ -1,7 +1,7 @@
1
1
  class Page
2
2
  include Mongoid::Document
3
3
  include Mongoid::Timestamps
4
- include Mongoid::History::Trackable
4
+ #include Mongoid::History::Trackable
5
5
  include Mongoid::Slug
6
6
 
7
7
  include StateMachines::Page
@@ -21,7 +21,7 @@ class Page
21
21
  validates :name, presence: true, uniqueness: true
22
22
  validates :text, presence: true
23
23
 
24
- track_history on: [:user_id, :name, :text, :state]
24
+ #track_history on: [:user_id, :name, :text, :state]
25
25
  slug :name
26
26
 
27
27
  # belongs_to (SQL)
@@ -5,22 +5,21 @@ class Product
5
5
  field :_id, type: String, default: -> { name.to_s.parameterize }
6
6
  field :user_id, type: Integer
7
7
  field :name, type: String, localize: true
8
+ field :klass_name, type: String
8
9
  field :text, type: String, localize: true
9
10
  field :area_ids, type: Array, default: []
10
11
  field :state, type: String
11
12
 
12
13
  attr_accessible :name, :text, :area_ids
13
14
 
14
- validates :user_id, presence: true
15
15
  validates :name, presence: true, uniqueness: true
16
- validates :area_ids, presence: true
17
16
 
18
17
  validate :english_name_available?
19
18
  validate :existing_model_file?
20
19
 
21
20
  index({ name: 1 }, { unique: true })
22
21
 
23
- before_validation :set_type
22
+ before_validation :set_klass_name
24
23
 
25
24
  # active record compatibility
26
25
  # just belongs_to reflections for cucumber's factory steps
@@ -75,15 +74,17 @@ class Product
75
74
  end
76
75
 
77
76
  def existing_model_file?
78
- unless (get_type.constantize rescue false)
77
+ unless (get_klass_name.constantize rescue false)
79
78
  errors[:name] << I18n.t(
80
79
  'activerecord.errors.models.product.attributes.name.missing_model_file'
81
80
  )
82
81
  end
83
82
  end
84
83
 
85
- def get_type
86
- if name == 'Product'
84
+ def get_klass_name
85
+ if klass_name.present?
86
+ klass_name
87
+ elsif name == 'Product'
87
88
  'Product'
88
89
  else
89
90
  [
@@ -92,8 +93,7 @@ class Product
92
93
  end
93
94
  end
94
95
 
95
- def set_type
96
- # TODO: check with a better internet connection a better regex on rubular.com
97
- self._type = get_type
96
+ def set_klass_name
97
+ self._type = get_klass_name
98
98
  end
99
99
  end
@@ -31,7 +31,14 @@ class Project < ActiveRecord::Base
31
31
 
32
32
  # belongs_to (Mongo DB)
33
33
  def product
34
- product_id.blank? ? nil : Product.find(product_id)
34
+ return @product if @product
35
+
36
+ @product = product_id.blank? ? nil : Product.find(product_id)
37
+ end
38
+
39
+ def product=(document)
40
+ @product = document
41
+ self.product_id = @product.try(:id)
35
42
  end
36
43
 
37
44
  # has_many (Mongo DB)
@@ -21,9 +21,9 @@ class Task
21
21
  field :state, type: String
22
22
  field :unassigned_user_ids, type: Array
23
23
 
24
- slug :name
24
+ slug :name, reserve: ['new', 'edit', 'next']
25
25
 
26
- attr_accessible :story_id, :name, :text, :result_attributes
26
+ attr_accessible :story, :story_id, :name, :text, :result_attributes
27
27
 
28
28
  scope :current, where(state: 'new')
29
29
  scope :unassigned, where(user_id: nil)
@@ -35,7 +35,6 @@ class Task
35
35
  validates :offeror_id, presence: true
36
36
  validates :name, presence: true, uniqueness: { scope: :story_id }
37
37
  validates :text, presence: true, if: ->(t) { t.class.name == 'Task' }
38
- validate :reserved_words_exclusion
39
38
 
40
39
  after_initialize :cache_associations
41
40
  before_validation :cache_associations
@@ -64,17 +63,6 @@ class Task
64
63
 
65
64
  private
66
65
 
67
- def reserved_words_exclusion
68
- current_slug = to_param
69
-
70
- if ['new', 'edit', 'next'].include?(current_slug)
71
- message = I18n.t(
72
- 'activerecord.errors.models.general.attributes.name.reserved_word_included'
73
- )
74
- errors[:name] << message unless errors[:name].include? message
75
- end
76
- end
77
-
78
66
  def cache_associations
79
67
  self.offeror_id = story.offeror_id if story_id.present? && (story rescue nil)
80
68
  end
@@ -23,9 +23,9 @@ class Shared::Collection::TablePresenter < Presenter
23
23
  return '' unless append_new_link
24
24
 
25
25
  path = if current_parent
26
- eval("new_#{root_model_class_name(current_parent).tableize.singularize}_#{type.singularize}_path(current_parent)")
26
+ eval("new_#{root_model_class_name(current_parent).tableize.singularize}_#{type.gsub('.', '_').singularize}_path(current_parent)")
27
27
  else
28
- eval("new_#{type.singularize}_path")
28
+ eval("new_#{type.gsub('.', '_').singularize}_path")
29
29
  end
30
30
 
31
31
  link_to t("#{type}.new.title"), path
@@ -11,6 +11,6 @@
11
11
  </div>
12
12
  <% content_for :document_ready do %>
13
13
  $( '.accordions' ).each(function(k, v) {
14
- $(v).accordion({ active: <%= wizard_steps.index(step) %> })
14
+ $(v).accordion({ active: <%= wizard_steps.index(step).to_i %> })
15
15
  })
16
16
  <% end %>
@@ -5,10 +5,16 @@
5
5
  <meta charset='utf-8'>
6
6
  <meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
7
7
  <%= stylesheet_link_tag 'voluntary/application', media: 'all' %>
8
+ <link href="//netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.css" rel="stylesheet"/>
8
9
  </head>
9
10
  <body>
10
11
  <%= render 'layouts/shared/navigation' %>
11
12
 
13
+ <section id="dialog">
14
+ <img alt="Ajax-loader-small" class="hide " id="dialog_body_spinner" src="<%=image_path('voluntary/spinner.gif')%>"/>
15
+ <div id="dialog_body"/>
16
+ </section>
17
+
12
18
  <div class="container-fluid">
13
19
  <% unless flash.empty? %>
14
20
  <div class="row-fluid">
@@ -1,6 +1,9 @@
1
- <div class="navbar">
1
+ <div class="navbar navbar-inverse navbar-fixed-top">
2
2
  <div class="navbar-inner">
3
3
  <div class="container">
4
+ <a id="plattform_brand" class="brand" href="#">Volontari.at /</a>
5
+ <a id="product_brand" class="brand" href="#">Core</a>
6
+
4
7
  <%= render_navigation context: :main, expand_all: false, renderer: :bootstrap %>
5
8
  </div>
6
9
  </div>
@@ -10,8 +10,6 @@
10
10
  <%= show_actions %>
11
11
  </dl>
12
12
 
13
- <%= render partial: 'shared/resource/actions', locals: { type: 'vacancies', resource: @vacancy } %>
14
-
15
13
  <%= markdown @vacancy.text %>
16
14
 
17
15
  <%= render 'shared/comments', comment: @vacancy.comments.new %>
@@ -0,0 +1,17 @@
1
+ class AddKlassNameToProducts < ActiveRecord::Migration
2
+ def up
3
+ Product.each do |product|
4
+ next if product.klass_name.present?
5
+
6
+ if product.name == 'Product'
7
+ product.klass_name = 'Product'
8
+ else
9
+ product.klass_name = [
10
+ 'Product', product.name.gsub(' - ', '_').gsub('-', '_').gsub(' ', '_').classify
11
+ ].join('::')
12
+ end
13
+
14
+ product.save!
15
+ end
16
+ end
17
+ end