openproject-auto_project 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eccb04402e850f9d71c5e5a10bfd848e7fa6fbfa
4
+ data.tar.gz: 342468ad2b18893fb2334af665c98e37bfb1f169
5
+ SHA512:
6
+ metadata.gz: a88dfa724a623cac8caa15e7ddafcf512f06e5a82641d1060e97e348e47e04e42e12e88c2b5372c9fa59c51b9bba8f7a628a5592973efd4a5dc7666e3247cbf5
7
+ data.tar.gz: ac55ae15c74fea1dd5d1ba8c56d36b9f9963fb12807c968c65e29deb871cf30cbf4c6b9dda96908d505be9db7b920c68ff74fb0bf1057665bab4f343159b5172
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # ChiliProject Auto-Project Plugin
2
+
3
+ This plugin creates a new top-level private project for new users.
4
+
5
+ ## Requirements
6
+
7
+ * OpenProject Version >= 3.0
8
+
9
+ ## Installation
10
+
11
+ Create a file `Gemfile.plugins` in your OpenProject installation with the following content:
12
+
13
+ gem "openproject-plugins", :git => "https://github.com/opf/openproject-plugins.git", :branch => "stable"
14
+ gem "openproject-auto_project", :git => "https://github.com/oliverguenther/openproject-auto_project.git", :branch => "master"
15
+
16
+
17
+ Please see the [OpenProject plugin overview](https://www.openproject.org/projects/openproject/wiki/OpenProject_Plug-Ins)
18
+ for more details.
19
+
20
+ ## License
21
+
22
+ Copyright (c) 2014 Oliver Günther (mail@oliverguenther.de)
23
+
24
+ This plugin is forked from the [ChiliProject Auto Project Plugin](https://github.com/thegcat/chiliproject_auto_project) by Felix Schäfer.
25
+
26
+ Copyright (c) 2011 Felix Schäfer
27
+
28
+ This plugin is licensed under the MIT license. See COPYING for details.
@@ -0,0 +1,11 @@
1
+ <h3>Plugin: AutoProject</h3>
2
+
3
+ <p>
4
+ <label><%= l(:label_user_project_role_id) %></label>
5
+ <%=
6
+ select_tag("settings[user_project_role_id]",
7
+ options_for_select(Role.find_all_givable.collect {|r| [r.name, r.id.to_s]}),
8
+ :blank => "--- #{l(:actionview_instancetag_blank_option)} ---"
9
+ )
10
+ %>
11
+ </p>
@@ -0,0 +1,3 @@
1
+ # German strings go here for Rails i18n
2
+ de:
3
+ label_user_project_role_id: Rolle des Nutzers für Projekt
@@ -0,0 +1,3 @@
1
+ # German strings go here for Rails i18n
2
+ en:
3
+ label_user_project_role_id: Assigned user role to project
@@ -0,0 +1,5 @@
1
+ module OpenProject
2
+ module AutoProject
3
+ require "open_project/auto_project/engine"
4
+ end
5
+ end
@@ -0,0 +1,29 @@
1
+ # Prevent load-order problems in case openproject-plugins is listed after a plugin in the Gemfile
2
+ # or not at all
3
+ require 'open_project/plugins'
4
+
5
+ module OpenProject::AutoProject
6
+ class Engine < ::Rails::Engine
7
+ engine_name :openproject_auto_project
8
+
9
+ include OpenProject::Plugins::ActsAsOpEngine
10
+
11
+
12
+ def self.settings
13
+ { :partial => 'settings/openproject_auto_project',
14
+ :default => {
15
+ # User role to assign to auto-projects.
16
+ :user_project_role_id => nil,
17
+ }
18
+ }
19
+ end
20
+
21
+ register 'openproject-auto_project',
22
+ :author_url => 'https://github.com/oliverguenther/openproject_auto_project',
23
+ :requires_openproject => '>= 3.0.0',
24
+ :settings => settings
25
+
26
+
27
+ patches [ :User ]
28
+ end
29
+ end
@@ -0,0 +1,2 @@
1
+ module OpenProject::AutoProject::Patches
2
+ end
@@ -0,0 +1,59 @@
1
+ module OpenProject::AutoProject
2
+ module Patches
3
+ module UserPatch
4
+
5
+ def self.included(base)
6
+ base.class_eval do
7
+ unloadable
8
+
9
+ include InstanceMethods
10
+
11
+ before_save :remember_if_activated
12
+ after_save :build_user_project
13
+ end
14
+ end
15
+
16
+
17
+ module InstanceMethods
18
+
19
+ def remember_if_activated
20
+ @was_activated = false
21
+ # Return unless user was registered, is now active
22
+ # Or the user is created and activated immediately
23
+ return unless ((self.status_change == [User::STATUSES[:registered], User::STATUSES[:active]] ) ||
24
+ (self.new_record? && self.status == User::STATUSES[:active]))
25
+
26
+ # Or the project exists already
27
+ return if Project.find_by_identifier user_project_identifier
28
+ @was_activated = true
29
+ end
30
+
31
+ def build_user_project
32
+ return unless @was_activated
33
+
34
+ user_project = Project.create :identifier => user_project_identifier, :name => name, :is_public => false
35
+ memberships.create :project => user_project, :roles => [user_project_role]
36
+ end
37
+
38
+ private
39
+
40
+ def user_project_identifier
41
+ login.gsub /[@.]/, '_'
42
+ end
43
+
44
+ def user_project_role
45
+ # Assign project role id by precedence:
46
+ # 1. Setting override within AP plugin
47
+ # 2. Default Project assigned role
48
+ # 3. First assignable role
49
+ id = Setting.plugin_openproject_auto_project[:user_project_role_id] ||
50
+ Setting.new_project_user_role_id.to_i
51
+
52
+ Role.givable.find_by_id(id) || Role.givable.first
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ User.send(:include, OpenProject::AutoProject::Patches::UserPatch)
@@ -0,0 +1,5 @@
1
+ module OpenProject
2
+ module AutoProject
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require 'open_project/auto_project'
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openproject-auto_project
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Oliver Günther
8
+ - Felix Schäfer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-07-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '3.2'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '3.2'
28
+ description: This plugin creates a new top-level private project for new users.
29
+ email: mail@oliverguenther.de
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - README.md
35
+ - app/views/settings/_openproject_auto_project.html.erb
36
+ - config/locales/de.yml
37
+ - config/locales/en.yml
38
+ - lib/open_project/auto_project.rb
39
+ - lib/open_project/auto_project/engine.rb
40
+ - lib/open_project/auto_project/patches.rb
41
+ - lib/open_project/auto_project/patches/user_patch.rb
42
+ - lib/open_project/auto_project/version.rb
43
+ - lib/openproject-auto_project.rb
44
+ homepage: https://www.github.com/oliverguenther/openproject-auto_project
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 2.2.2
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: Auto Project
68
+ test_files: []
69
+ has_rdoc: