redmine_extensions 0.6.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -32
- data/Rakefile +0 -8
- data/app/assets/javascripts/redmine_extensions/blocking.js +0 -3
- data/app/assets/javascripts/redmine_extensions/blocking_namespace.js +1 -2
- data/app/assets/javascripts/redmine_extensions/redmine_extensions.js +1 -33
- data/config/routes.rb +0 -7
- data/lib/redmine_extensions/easy_settings.rb +5 -5
- data/lib/redmine_extensions/engine.rb +12 -32
- data/lib/redmine_extensions/hooks.rb +6 -35
- data/lib/redmine_extensions/version.rb +1 -1
- data/lib/redmine_extensions.rb +5 -2
- data/spec/spec_helper.rb +10 -2
- metadata +3 -76
- data/app/assets/javascripts/redmine_extensions/blocking_render.js +0 -137
- data/app/assets/javascripts/redmine_extensions/blocking_schedule.js +0 -280
- data/app/assets/javascripts/redmine_extensions/event_bus.js +0 -61
- data/app/assets/stylesheets/redmine_extensions/application.css +0 -15
- data/lib/generators/redmine_extensions/entity/USAGE +0 -11
- data/lib/generators/redmine_extensions/entity/entity_generator.rb +0 -418
- data/lib/generators/redmine_extensions/entity/templates/_form.html.erb.erb +0 -51
- data/lib/generators/redmine_extensions/entity/templates/_list.html.erb.erb +0 -70
- data/lib/generators/redmine_extensions/entity/templates/_sidebar.html.erb.erb +0 -9
- data/lib/generators/redmine_extensions/entity/templates/app/models/%model_name_underscored%_query.rb.tt +0 -42
- data/lib/generators/redmine_extensions/entity/templates/app/views/%model_name_pluralize_underscored%/_%model_name_underscored%.api.rsb.tt +0 -18
- data/lib/generators/redmine_extensions/entity/templates/app/views/%model_name_pluralize_underscored%/_form.html.erb.tt +0 -62
- data/lib/generators/redmine_extensions/entity/templates/app/views/%model_name_pluralize_underscored%/edit.html.erb.tt +0 -8
- data/lib/generators/redmine_extensions/entity/templates/app/views/%model_name_pluralize_underscored%/new.html.erb.tt +0 -8
- data/lib/generators/redmine_extensions/entity/templates/context_menu.html.erb.erb +0 -20
- data/lib/generators/redmine_extensions/entity/templates/controller.rb.erb +0 -208
- data/lib/generators/redmine_extensions/entity/templates/custom_field.rb.erb +0 -11
- data/lib/generators/redmine_extensions/entity/templates/easy_query.rb.erb +0 -37
- data/lib/generators/redmine_extensions/entity/templates/edit.html.erb.erb +0 -19
- data/lib/generators/redmine_extensions/entity/templates/edit.js.erb.erb +0 -18
- data/lib/generators/redmine_extensions/entity/templates/en.yml.erb +0 -16
- data/lib/generators/redmine_extensions/entity/templates/entity_attribute_helper_patch.rb.erb +0 -10
- data/lib/generators/redmine_extensions/entity/templates/helper.rb.erb +0 -3
- data/lib/generators/redmine_extensions/entity/templates/hooks.rb.erb +0 -5
- data/lib/generators/redmine_extensions/entity/templates/index.api.rsb.erb +0 -3
- data/lib/generators/redmine_extensions/entity/templates/index.html.erb.erb +0 -30
- data/lib/generators/redmine_extensions/entity/templates/index.js.erb.erb +0 -12
- data/lib/generators/redmine_extensions/entity/templates/mail_added.html.erb.erb +0 -1
- data/lib/generators/redmine_extensions/entity/templates/mail_added.text.erb.erb +0 -2
- data/lib/generators/redmine_extensions/entity/templates/mail_updated.html.erb.erb +0 -1
- data/lib/generators/redmine_extensions/entity/templates/mail_updated.text.erb.erb +0 -2
- data/lib/generators/redmine_extensions/entity/templates/mailer.rb.erb +0 -41
- data/lib/generators/redmine_extensions/entity/templates/migration.rb.erb +0 -16
- data/lib/generators/redmine_extensions/entity/templates/model.rb.erb +0 -143
- data/lib/generators/redmine_extensions/entity/templates/new.html.erb.erb +0 -19
- data/lib/generators/redmine_extensions/entity/templates/new.js.erb.erb +0 -18
- data/lib/generators/redmine_extensions/entity/templates/query.rb.erb +0 -67
- data/lib/generators/redmine_extensions/entity/templates/routes.rb.erb +0 -15
- data/lib/generators/redmine_extensions/entity/templates/show.api.rsb.erb +0 -1
- data/lib/generators/redmine_extensions/entity/templates/show.html.erb.erb +0 -50
- data/lib/generators/redmine_extensions/entity/templates/show.js.erb.erb +0 -12
- data/lib/generators/redmine_extensions/entity/templates/spec/controllers/%model_name_underscored%_controller_spec.rb.tt +0 -94
- data/lib/generators/redmine_extensions/entity/templates/spec/factories.rb.erb +0 -11
- data/lib/generators/redmine_extensions/entity/templates/spec/requests/%model_name_underscored%_spec.rb.tt +0 -19
- data/lib/generators/redmine_extensions/plugin/USAGE +0 -13
- data/lib/generators/redmine_extensions/plugin/plugin_generator.rb +0 -74
- data/lib/generators/redmine_extensions/plugin/templates/Gemfile.erb +0 -1
- data/lib/generators/redmine_extensions/plugin/templates/after_init.rb.erb +0 -23
- data/lib/generators/redmine_extensions/plugin/templates/en.yml.erb +0 -3
- data/lib/generators/redmine_extensions/plugin/templates/gitkeep.erb +0 -0
- data/lib/generators/redmine_extensions/plugin/templates/hooks.rb.erb +0 -5
- data/lib/generators/redmine_extensions/plugin/templates/init.rb.erb +0 -20
- data/lib/generators/redmine_extensions/plugin/templates/internals.rb.erb +0 -4
- data/lib/generators/redmine_extensions/plugin/templates/issue_patch.example.erb +0 -30
- data/lib/generators/redmine_extensions/plugin/templates/issues_controller_patch.example.erb +0 -30
- data/lib/generators/redmine_extensions/plugin/templates/issues_helper_patch.example.erb +0 -30
- data/lib/generators/redmine_extensions/plugin/templates/javascript.js +0 -1
- data/lib/generators/redmine_extensions/plugin/templates/routes.rb.erb +0 -0
- data/lib/generators/redmine_extensions/plugin/templates/stylesheet.css +0 -3
- data/lib/redmine_extensions/core_ext/date_range.rb +0 -152
- data/lib/redmine_extensions/core_ext/object.rb +0 -19
- data/lib/redmine_extensions/core_ext/string.rb +0 -5
- data/lib/redmine_extensions/core_ext.rb +0 -3
- data/lib/redmine_extensions/deprecator.rb +0 -11
- data/lib/redmine_extensions/migration.rb +0 -9
- data/lib/redmine_extensions/patch_manager.rb +0 -440
- data/lib/redmine_extensions/rails_patches/route_set_generator_patch.rb +0 -10
- data/lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb +0 -65
- data/lib/redmine_extensions/redmine_patches/models/custom_field_patch.rb +0 -11
- data/lib/redmine_extensions/redmine_patches/models/project_patch.rb +0 -10
- data/lib/tasks/redmine_extensions_tasks.rake +0 -4
- data/spec/init_rails.rb +0 -13
@@ -1,143 +0,0 @@
|
|
1
|
-
class <%= model_name %> < ActiveRecord::Base
|
2
|
-
include Redmine::SafeAttributes
|
3
|
-
|
4
|
-
<%= 'belongs_to :project' if project? %>
|
5
|
-
<%= 'belongs_to :author, class_name: \'User\'' if author? %>
|
6
|
-
|
7
|
-
scope :visible, ->(*args) { where(<%= model_name %>.visible_condition(args.shift || User.current, *args))<%= '.joins(:project)' if project? %> }
|
8
|
-
<% if name_column? %>
|
9
|
-
scope :sorted, -> { order("#{table_name}.<%= name_column %> ASC") }
|
10
|
-
<% end %>
|
11
|
-
|
12
|
-
<%- if acts_as_searchable? -%>
|
13
|
-
acts_as_searchable columns: [<%= string_columns.collect{|c, _| "\"\#{#{model_name}.table_name}.#{c}\"" }.join(', ') %>],
|
14
|
-
date_column: :created_at
|
15
|
-
<%- end -%>
|
16
|
-
<%- if acts_as_customizable? -%>
|
17
|
-
acts_as_customizable
|
18
|
-
<%- end -%>
|
19
|
-
<%- if acts_as_attachable? -%>
|
20
|
-
acts_as_attachable
|
21
|
-
<%- end -%>
|
22
|
-
<%- if acts_as_event? -%>
|
23
|
-
acts_as_event title: ->(o){"#{l(:label_<%= model_name_underscored %>)} - #{o.to_s}"},
|
24
|
-
url: ->(o){{controller: '<%= model_name_pluralize_underscored %>', action: 'show', id: o, project_id: o.project}},
|
25
|
-
datetime: :created_at, description: :<%= description_column || name_column %>
|
26
|
-
<%- end -%>
|
27
|
-
<%- if acts_as_activity_provider? -%>
|
28
|
-
acts_as_activity_provider author_key: <%= author? ? ':author_id' : 'nil' %>, timestamp: "#{table_name}.created_at"
|
29
|
-
<%- end -%>
|
30
|
-
<%- if acts_as_watchable? -%>
|
31
|
-
acts_as_watchable
|
32
|
-
<%- end -%>
|
33
|
-
|
34
|
-
<%= 'validates :project_id, presence: true' if project? %>
|
35
|
-
<%= 'validates :author_id, presence: true' if author? %>
|
36
|
-
<%= "validates :#{safe_columns.keys.first}, presence: true" if safe_columns.any? %>
|
37
|
-
|
38
|
-
<%- if associations.any? -%>
|
39
|
-
<%- associations.each do |assoc_name, values| -%>
|
40
|
-
<%- options = ''-%>
|
41
|
-
<%- options = ", class_name: '#{values[:class]}'" if values[:class].present? -%>
|
42
|
-
<%= values[:type] %> :<%= assoc_name %><%= options %>
|
43
|
-
<%- end -%>
|
44
|
-
<%- end -%>
|
45
|
-
<%- attributes = [] -%>
|
46
|
-
<%- attributes += safe_columns.keys if safe_columns.any? -%>
|
47
|
-
<%- attributes += ['custom_field_values', 'custom_fields'] if acts_as_customizable? -%>
|
48
|
-
<%-attributes += associations.keys.map{ |assoc| "#{assoc}_id" } -%>
|
49
|
-
safe_attributes *%w[<%= attributes.join(' ') %>]
|
50
|
-
<%- if project? -%>
|
51
|
-
safe_attributes 'project_id', if: ->(<%= model_name_underscored %>, _user) { <%= model_name_underscored %>.new_record? }
|
52
|
-
<%- end -%>
|
53
|
-
|
54
|
-
<%- if mail? -%>
|
55
|
-
after_create :send_create_notification
|
56
|
-
after_update :send_update_notification
|
57
|
-
<%- end -%>
|
58
|
-
|
59
|
-
def self.visible_condition(user, options = {})
|
60
|
-
<%- if project? -%>
|
61
|
-
Project.allowed_to_condition(user, :<%= view_permission %>, options)
|
62
|
-
<%- else -%>
|
63
|
-
'1=1'
|
64
|
-
<%- end -%>
|
65
|
-
end
|
66
|
-
|
67
|
-
def self.css_icon
|
68
|
-
'icon icon-user'
|
69
|
-
end
|
70
|
-
|
71
|
-
def editable_by?(user)
|
72
|
-
editable?(user)
|
73
|
-
end
|
74
|
-
|
75
|
-
<%- if !project? -%>
|
76
|
-
def project
|
77
|
-
nil
|
78
|
-
end
|
79
|
-
<%- end -%>
|
80
|
-
|
81
|
-
def visible?(user = nil)
|
82
|
-
user ||= User.current
|
83
|
-
user.allowed_to?(:<%= view_permission %>, project, global: true)
|
84
|
-
end
|
85
|
-
|
86
|
-
def editable?(user = nil)
|
87
|
-
user ||= User.current
|
88
|
-
user.allowed_to?(:<%= edit_permission %>, project, global: true)
|
89
|
-
end
|
90
|
-
|
91
|
-
def deletable?(user = nil)
|
92
|
-
user ||= User.current
|
93
|
-
user.allowed_to?(:<%= delete_permission %>, project, global: true)
|
94
|
-
end
|
95
|
-
|
96
|
-
def attachments_visible?(user = nil)
|
97
|
-
visible?(user)
|
98
|
-
end
|
99
|
-
|
100
|
-
def attachments_editable?(user = nil)
|
101
|
-
editable?(user)
|
102
|
-
end
|
103
|
-
|
104
|
-
def attachments_deletable?(user = nil)
|
105
|
-
deletable?(user)
|
106
|
-
end
|
107
|
-
|
108
|
-
<%- if name_column? -%>
|
109
|
-
def to_s
|
110
|
-
<%= name_column %>.to_s
|
111
|
-
end
|
112
|
-
<%- end -%>
|
113
|
-
|
114
|
-
alias_attribute :created_on, :created_at
|
115
|
-
alias_attribute :updated_on, :updated_at
|
116
|
-
|
117
|
-
<%- if mail? -%>
|
118
|
-
def notified_users
|
119
|
-
if project
|
120
|
-
project.notified_users.reject {|user| !visible?(user)}
|
121
|
-
else
|
122
|
-
[User.current]
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
def send_create_notification
|
127
|
-
# if Setting.notified_events.include?('<%= model_name_underscored %>_added')
|
128
|
-
notified_users.each do |user|
|
129
|
-
<%= model_name %>Mailer.<%= model_name_underscored %>_added(user, self).deliver
|
130
|
-
end
|
131
|
-
# end
|
132
|
-
end
|
133
|
-
|
134
|
-
def send_update_notification
|
135
|
-
# if Setting.notified_events.include?('<%= model_name_underscored %>_updated')
|
136
|
-
notified_users.each do |user|
|
137
|
-
<%= model_name %>Mailer.<%= model_name_underscored %>_updated(user, self).deliver
|
138
|
-
end
|
139
|
-
# end
|
140
|
-
end
|
141
|
-
<%- end -%>
|
142
|
-
|
143
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<%%= title l(:heading_<%= model_name_underscored %>_new) %>
|
2
|
-
|
3
|
-
<%%= form_for([@project, @<%= model_name_underscored %>], html: { multipart: <%= acts_as_attachable? %>, id: '<%= model_name_underscored %>_form', class: 'tabular', remote: request.xhr? }) do |f| %>
|
4
|
-
<%%= error_messages_for @<%= model_name_underscored %> %>
|
5
|
-
|
6
|
-
<div class="box">
|
7
|
-
<%%= render partial: 'form', locals: { <%= model_name_underscored %>: @<%= model_name_underscored %> } %>
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<%% if !request.xhr? %>
|
11
|
-
<p>
|
12
|
-
<%%= submit_tag l(:button_create), title: l(:button_create) %>
|
13
|
-
</p>
|
14
|
-
<%% end %>
|
15
|
-
<%% end %>
|
16
|
-
<%% ### PAGE CUSTOMS ########################################################## %>
|
17
|
-
<%% content_for :sidebar do %>
|
18
|
-
<%%= render partial: '<%= model_name_pluralize_underscored %>/sidebar' %>
|
19
|
-
<%% end %>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
var modal = $("#ajax-modal");
|
2
|
-
modal.html("<%%= j render(template: '<%= model_name_pluralize_underscored %>/new', formats: [:html]) %>");
|
3
|
-
showModal(modal.attr("id"));
|
4
|
-
var submitButton = {
|
5
|
-
text:"<%%=j l(:button_create) %>",
|
6
|
-
title:"<%%=j l(:button_create) %>",
|
7
|
-
click: function() {$(this).find('form').submit()},
|
8
|
-
'class': 'button-positive'
|
9
|
-
};
|
10
|
-
var closeButton = {
|
11
|
-
text: "<%%=j l(:button_close) %>",
|
12
|
-
title: "<%%=j l(:button_close) %>",
|
13
|
-
click: function() {$(this).dialog('close');},
|
14
|
-
'class': 'button'
|
15
|
-
};
|
16
|
-
modal.dialog('option', {
|
17
|
-
buttons: [closeButton, submitButton]
|
18
|
-
});
|
@@ -1,67 +0,0 @@
|
|
1
|
-
class <%= model_name %>Query < Query
|
2
|
-
|
3
|
-
self.queried_class = <%= model_name %>
|
4
|
-
|
5
|
-
def initialize_available_filters
|
6
|
-
<%- db_columns.each do |column_name, column_options| -%>
|
7
|
-
<%- if project? && column_name == 'project_id' -%>
|
8
|
-
if project.nil?
|
9
|
-
add_available_filter '<%= column_name %>', name: <%= model_name %>.human_attribute_name(:<%= column_name %>), type: :<%= column_options[:query_type] %>, values: all_projects_values
|
10
|
-
end
|
11
|
-
<%- else -%>
|
12
|
-
add_available_filter '<%= column_name %>', name: <%= model_name %>.human_attribute_name(:<%= column_name %>), type: :<%= column_options[:query_type] %>
|
13
|
-
<%- end -%>
|
14
|
-
<%- end -%>
|
15
|
-
|
16
|
-
<%- if acts_as_customizable? -%>
|
17
|
-
add_custom_fields_filters(<%= model_name %>CustomField)
|
18
|
-
<%- end -%>
|
19
|
-
end
|
20
|
-
|
21
|
-
def available_columns
|
22
|
-
return @available_columns if @available_columns
|
23
|
-
@available_columns = []
|
24
|
-
group = l("label_filter_group_#{self.class.name.underscore}")
|
25
|
-
|
26
|
-
<%- db_columns.each do |column_name, column_options| -%>
|
27
|
-
@available_columns << QueryColumn.new(:<%= column_options[:query_column_name] || column_name %>, caption: <%= model_name %>.human_attribute_name(:<%= column_name %>), title: <%= model_name %>.human_attribute_name(:<%= column_name %>), group: group)
|
28
|
-
<%- end -%>
|
29
|
-
<%- if acts_as_customizable? -%>
|
30
|
-
@available_columns += <%= model_name %>CustomField.visible.collect { |cf| QueryCustomFieldColumn.new(cf) }
|
31
|
-
<%- end -%>
|
32
|
-
|
33
|
-
@available_columns
|
34
|
-
end
|
35
|
-
|
36
|
-
def initialize(attributes=nil, *args)
|
37
|
-
super attributes
|
38
|
-
self.filters ||= { "<%= db_columns.first[0] %>" => {:operator => "*", :values => []} }
|
39
|
-
end
|
40
|
-
|
41
|
-
def default_columns_names
|
42
|
-
super.presence || <%= db_columns.collect{|column_name, column_options| (column_options[:query_column_name] || column_name).to_s}[0..3].to_s %>.flat_map{|c| [c.to_s, c.to_sym]}
|
43
|
-
end
|
44
|
-
|
45
|
-
def <%= model_name_pluralize_underscored %>(options={})
|
46
|
-
order_option = [group_by_sort_order, (options[:order] || sort_clause)].flatten.reject(&:blank?)
|
47
|
-
|
48
|
-
scope = <%= model_name %>.visible.
|
49
|
-
where(statement).
|
50
|
-
includes(((options[:include] || [])).uniq).
|
51
|
-
where(options[:conditions]).
|
52
|
-
order(order_option).
|
53
|
-
joins(joins_for_order_statement(order_option.join(','))).
|
54
|
-
limit(options[:limit]).
|
55
|
-
offset(options[:offset])
|
56
|
-
|
57
|
-
if has_custom_field_column?
|
58
|
-
scope = scope.preload(:custom_values)
|
59
|
-
end
|
60
|
-
|
61
|
-
<%= model_name_pluralize_underscored %> = scope.to_a
|
62
|
-
|
63
|
-
<%= model_name_pluralize_underscored %>
|
64
|
-
rescue ::ActiveRecord::StatementInvalid => e
|
65
|
-
raise StatementInvalid.new(e.message)
|
66
|
-
end
|
67
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
|
2
|
-
<% if project? %>
|
3
|
-
resources :projects do
|
4
|
-
resources :<%= model_name_pluralize_underscored %>
|
5
|
-
end
|
6
|
-
<% end %>
|
7
|
-
resources :<%= model_name_pluralize_underscored %> do
|
8
|
-
collection do
|
9
|
-
get 'autocomplete'
|
10
|
-
get 'bulk_edit'
|
11
|
-
post 'bulk_update'
|
12
|
-
get 'context_menu'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
render(@<%= model_name_underscored %>, { api: api })
|
@@ -1,50 +0,0 @@
|
|
1
|
-
<%%= title @<%= model_name_underscored %> %>
|
2
|
-
<div class="issue">
|
3
|
-
<table class="attributes">
|
4
|
-
<%%= issue_fields_rows do |rows| %>
|
5
|
-
<%- safe_columns.each_with_index do |column, idx| -%>
|
6
|
-
<%- next if description_column? && column[0] == description_column -%>
|
7
|
-
<%- if idx % 2 == 0 -%>
|
8
|
-
<%% rows.left ::<%= model_name %>.human_attribute_name(:<%= column[0] %>), format_object(@<%= model_name_underscored %>.<%= column[0] %>) %>
|
9
|
-
<%- else -%>
|
10
|
-
<%% rows.right ::<%= model_name %>.human_attribute_name(:<%= column[0] %>), format_object(@<%= model_name_underscored %>.<%= column[0] %>) %>
|
11
|
-
<%- end -%>
|
12
|
-
<%- end -%>
|
13
|
-
<% associations.each_with_index do |assoc, idx| %>
|
14
|
-
<%- next if assoc[1][:type] == 'has_many' -%>
|
15
|
-
<% association_name = assoc[0] %>
|
16
|
-
<%- if idx % 2 == 0 -%>
|
17
|
-
<%% rows.left l(:label_<%= association_name %>), format_object(@<%= model_name_underscored %>.<%= association_name %>) %>
|
18
|
-
<%- else -%>
|
19
|
-
<%% rows.right l(:label_<%= association_name %>), format_object(@<%= model_name_underscored %>.<%= association_name %>) %>
|
20
|
-
<%- end -%>
|
21
|
-
<%- end -%>
|
22
|
-
<%% end %>
|
23
|
-
<%- if acts_as_customizable? -%>
|
24
|
-
<hr />
|
25
|
-
<%%= render partial: 'redmine_extensions/custom_field_rows', locals: { custom_field_values: @<%= model_name_underscored %>.visible_custom_field_values } %>
|
26
|
-
<%- end -%>
|
27
|
-
<%%= call_hook(:view_<%= model_name_pluralize_underscored %>_show_details_bottom, <%= model_name_underscored%>: @<%= model_name_underscored %>) %>
|
28
|
-
</table>
|
29
|
-
<%- if description_column? -%>
|
30
|
-
<%% if !@<%= model_name_underscored %>.<%= description_column %>.blank? %>
|
31
|
-
<hr />
|
32
|
-
<div class="description">
|
33
|
-
<p><strong><%%= ::<%= model_name %>.human_attribute_name(:<%= description_column %>) %></strong></p>
|
34
|
-
<div class="wiki">
|
35
|
-
<%%= textilizable @<%= model_name_underscored %>, :<%= description_column %>, attachments: @<%= model_name_underscored %>.attachments %>
|
36
|
-
</div>
|
37
|
-
</div>
|
38
|
-
<%% end %>
|
39
|
-
<%- end -%>
|
40
|
-
<%- if acts_as_attachable? -%>
|
41
|
-
<%% if @<%= model_name_underscored %>.attachments.any? %>
|
42
|
-
<hr />
|
43
|
-
<%%= link_to_attachments @<%= model_name_underscored %>, thumbnails: true %>
|
44
|
-
<%% end %>
|
45
|
-
<%- end -%>
|
46
|
-
</div>
|
47
|
-
<%% ### PAGE CUSTOMS ########################################################## %>
|
48
|
-
<%% content_for :sidebar do %>
|
49
|
-
<%%= render partial: '<%= model_name_pluralize_underscored %>/sidebar' %>
|
50
|
-
<%% end %>
|
@@ -1,12 +0,0 @@
|
|
1
|
-
var modal = $("#ajax-modal");
|
2
|
-
modal.html("<%%= j render(template: '<%= model_name_pluralize_underscored %>/show', formats: [:html]) %>");
|
3
|
-
showModal(modal.attr("id"));
|
4
|
-
var closeButton = {
|
5
|
-
text: "<%%=j l(:button_close) %>",
|
6
|
-
title: "<%%=j l(:button_close) %>",
|
7
|
-
click: function() {$(this).dialog('close');},
|
8
|
-
'class': 'button'
|
9
|
-
};
|
10
|
-
modal.dialog('option', {
|
11
|
-
buttons: [closeButton, submitButton]
|
12
|
-
});
|
@@ -1,94 +0,0 @@
|
|
1
|
-
<%- unless rys %>
|
2
|
-
require "easy_extensions/spec_helper"
|
3
|
-
|
4
|
-
<% end %>
|
5
|
-
RSpec.describe <%= controller_class %>Controller, logged: true do
|
6
|
-
|
7
|
-
describe "#index" do
|
8
|
-
before :each do
|
9
|
-
role = Role.non_member
|
10
|
-
role.add_permission! :view_<%= model_name_pluralize_underscored %>
|
11
|
-
end
|
12
|
-
|
13
|
-
it "html" do
|
14
|
-
get :index
|
15
|
-
expect(response).to have_http_status :success
|
16
|
-
end
|
17
|
-
|
18
|
-
it "json" do
|
19
|
-
get :index, params: { format: "json" }
|
20
|
-
expect(response).to have_http_status :ok
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#show" do
|
25
|
-
before :each do
|
26
|
-
role = Role.non_member
|
27
|
-
role.add_permission! :view_<%= model_name_pluralize_underscored %>
|
28
|
-
end
|
29
|
-
subject { FactoryBot.create(:<%= model_name_underscored %>) }
|
30
|
-
|
31
|
-
it "with id" do
|
32
|
-
get :show, params: { id: subject.id }
|
33
|
-
expect(response).to have_http_status :success
|
34
|
-
end
|
35
|
-
|
36
|
-
it "not found" do
|
37
|
-
get :show, params: { id: "invalid" }
|
38
|
-
expect(response).to have_http_status :not_found
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "manage <%= model_name_pluralize_underscored %>" do
|
43
|
-
before :each do
|
44
|
-
role = Role.non_member
|
45
|
-
role.add_permission! :manage_<%= model_name_pluralize_underscored %>
|
46
|
-
end
|
47
|
-
describe "#create" do
|
48
|
-
it "valid" do
|
49
|
-
expect {
|
50
|
-
post :create, params: { <%= model_name_underscored %>: FactoryBot.attributes_for(:<%= model_name_underscored %>), format: "json" }
|
51
|
-
}.to change(<%= model_name %>, :count).by 1
|
52
|
-
expect(response).to have_http_status :success
|
53
|
-
end
|
54
|
-
|
55
|
-
it "invalid" do
|
56
|
-
expect {
|
57
|
-
post :create, params: { <%= model_name_underscored %>: { <%= safe_columns.first[0] %>: "" }, format: "xml" }
|
58
|
-
}.to change(<%= model_name %>, :count).by 0
|
59
|
-
expect(response).to have_http_status :unprocessable_entity
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "#update" do
|
64
|
-
subject { FactoryBot.create(:<%= model_name_underscored %>, <%= safe_columns.first[0] %>: 'value1') }
|
65
|
-
it "valid" do
|
66
|
-
expect {
|
67
|
-
put :update, params: { id: subject, <%= model_name_underscored %>: FactoryBot.attributes_for(:<%= model_name_underscored %>), format: "json" }; subject.reload
|
68
|
-
}.to change(subject, :<%= safe_columns.first[0] %>)
|
69
|
-
expect(response).to have_http_status :success
|
70
|
-
end
|
71
|
-
|
72
|
-
it "invalid" do
|
73
|
-
expect {
|
74
|
-
put :update, params: { id: subject, <%= model_name_underscored %>: { <%= safe_columns.first[0] %>: '' }, format: "xml" }; subject.reload
|
75
|
-
}.not_to change(subject, :<%= safe_columns.first[0] %>)
|
76
|
-
expect(response).to have_http_status :unprocessable_entity
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "#destroy" do
|
81
|
-
before :each do
|
82
|
-
Role.non_member.add_permission! :view_<%= model_name_pluralize_underscored %>
|
83
|
-
end
|
84
|
-
subject! { FactoryBot.create(:<%= model_name_underscored %>) }
|
85
|
-
it { expect { delete :destroy, params: { id: subject } }.to change(<%= model_name %>, :count).by -1 }
|
86
|
-
|
87
|
-
it "record not found" do
|
88
|
-
expect { delete :destroy, params: { id: "none", format: "json" } }.to change(<%= model_name %>, :count).by 0
|
89
|
-
expect(response).to have_http_status :not_found
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
|
3
|
-
factory :<%= model_name_underscored %> do
|
4
|
-
<%- string_columns.each_key do |c| -%>
|
5
|
-
sequence(:<%= c %>) { |n| "<%= c %>-#{n}"}
|
6
|
-
<%- end -%>
|
7
|
-
<%= 'association :author, factory: :user' if author? %>
|
8
|
-
<%= 'project' if project? %>
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
RSpec.describe "<%= model_name_pluralize_underscored %>", type: :request do
|
2
|
-
describe "API" do
|
3
|
-
context "logged", logged: true do
|
4
|
-
before(:each) do
|
5
|
-
role = Role.non_member
|
6
|
-
role.add_permission! :view_<%= model_name_pluralize_underscored %>
|
7
|
-
end
|
8
|
-
|
9
|
-
it "list" do
|
10
|
-
FactoryBot.create_list :<%= model_name_underscored %>, 2
|
11
|
-
get <%= model_name_pluralize_underscored %>_path(format: "json")
|
12
|
-
expect(response).to have_http_status :success
|
13
|
-
expect(response.body).to include "limit", "offset"
|
14
|
-
expect(response.body).to match /total_count.{,2}:2/
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
Description:
|
2
|
-
The plugin generator creates stubs for new Redmine plugin.
|
3
|
-
Plugin is prepared for use in Redmine and Easy Redmine as well.
|
4
|
-
You can use --customer flag to generate a special plugin if you can make just a few changes to code. Backup this plugin before Redmine or Easy Redmine upgrade and move back for keep you changes.
|
5
|
-
You can use --easy_plugin flag to specify easy plugin build.
|
6
|
-
|
7
|
-
Example:
|
8
|
-
rails g redmine_extensions:plugin NameOfNewPlugin
|
9
|
-
create plugins/name_of_new_plugin/app/controllers
|
10
|
-
...
|
11
|
-
|
12
|
-
Help:
|
13
|
-
rails g redmine_extensions:plugin --help
|
@@ -1,74 +0,0 @@
|
|
1
|
-
module RedmineExtensions
|
2
|
-
class PluginGenerator < Rails::Generators::NamedBase
|
3
|
-
source_root File.expand_path('../templates', __FILE__)
|
4
|
-
|
5
|
-
attr_reader :plugin_path, :plugin_name_underscored, :plugin_pretty_name, :plugin_title, :easy_plugin
|
6
|
-
|
7
|
-
class_option :customer, type: :boolean, default: false, banner: '', :desc => 'plugin will act as customer modification. It is useful for changing few things and be uptodate with the core.'
|
8
|
-
class_option :easy_plugin, type: :boolean, default: false, banner: '', :desc => 'generate easy plugin'
|
9
|
-
|
10
|
-
def initialize(*args)
|
11
|
-
super
|
12
|
-
@easy_plugin = options[:easy_plugin]
|
13
|
-
@plugin_name_underscored = options[:customer] ? "modification_#{file_name.underscore}" : file_name.underscore
|
14
|
-
@plugin_pretty_name = plugin_name_underscored.titleize
|
15
|
-
|
16
|
-
@plugin_path = (easy_plugin ? "plugins/easyproject/easy_plugins" : "plugins") + "/#{plugin_name_underscored}"
|
17
|
-
@plugin_title = @plugin_name_underscored.camelize
|
18
|
-
check_existing_const
|
19
|
-
end
|
20
|
-
|
21
|
-
def check_existing_const
|
22
|
-
begin
|
23
|
-
@plugin_title.constantize
|
24
|
-
raise I18n.t(:error_plugin_name_is_used, plugin_name: @plugin_title)
|
25
|
-
rescue LoadError, NameError
|
26
|
-
# OK
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def copy_templates
|
31
|
-
empty_directory "#{plugin_path}/app"
|
32
|
-
empty_directory "#{plugin_path}/app/controllers"
|
33
|
-
empty_directory "#{plugin_path}/app/helpers"
|
34
|
-
empty_directory "#{plugin_path}/app/models"
|
35
|
-
empty_directory "#{plugin_path}/app/views"
|
36
|
-
empty_directory "#{plugin_path}/db/migrate"
|
37
|
-
empty_directory "#{plugin_path}/db/data"
|
38
|
-
empty_directory "#{plugin_path}/assets/images"
|
39
|
-
empty_directory "#{plugin_path}/assets/javascripts"
|
40
|
-
empty_directory "#{plugin_path}/assets/stylesheets"
|
41
|
-
empty_directory "#{plugin_path}/config/locales"
|
42
|
-
empty_directory "#{plugin_path}/lib/#{plugin_name_underscored}"
|
43
|
-
|
44
|
-
empty_directory "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/controllers"
|
45
|
-
empty_directory "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/helpers"
|
46
|
-
empty_directory "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/models"
|
47
|
-
empty_directory "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/others"
|
48
|
-
|
49
|
-
template 'gitkeep.erb', "#{plugin_path}/app/controllers/.gitkeep"
|
50
|
-
template 'gitkeep.erb', "#{plugin_path}/app/helpers/.gitkeep"
|
51
|
-
template 'gitkeep.erb', "#{plugin_path}/app/models/.gitkeep"
|
52
|
-
template 'gitkeep.erb', "#{plugin_path}/app/views/.gitkeep"
|
53
|
-
template 'gitkeep.erb', "#{plugin_path}/db/migrate/.gitkeep"
|
54
|
-
template 'gitkeep.erb', "#{plugin_path}/assets/images/.gitkeep"
|
55
|
-
template 'gitkeep.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/others/.gitkeep"
|
56
|
-
|
57
|
-
template 'after_init.rb.erb', "#{plugin_path}/after_init.rb"
|
58
|
-
template 'Gemfile.erb', "#{plugin_path}/Gemfile" unless easy_plugin
|
59
|
-
template 'init.rb.erb', "#{plugin_path}/init.rb"
|
60
|
-
template 'javascript.js', "#{plugin_path}/assets/javascripts/#{plugin_name_underscored}.js"
|
61
|
-
template 'stylesheet.css', "#{plugin_path}/assets/stylesheets/#{plugin_name_underscored}.css"
|
62
|
-
template 'en.yml.erb', "#{plugin_path}/config/locales/en.yml"
|
63
|
-
template 'routes.rb.erb', "#{plugin_path}/config/routes.rb"
|
64
|
-
template 'hooks.rb.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/hooks.rb"
|
65
|
-
template 'internals.rb.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/internals.rb"
|
66
|
-
template 'issue_patch.example.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/models/issue_patch.example"
|
67
|
-
template 'issues_controller_patch.example.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/controllers/issues_controller_patch.example"
|
68
|
-
template 'issues_helper_patch.example.erb', "#{plugin_path}/lib/#{plugin_name_underscored}/easy_patch/redmine/helpers/issues_helper_patch.example"
|
69
|
-
end
|
70
|
-
|
71
|
-
hook_for :entity, as: :entity, in: :redmine_extensions, type: :boolean
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
gem 'redmine_extensions' unless Dir.exist?(File.expand_path('../../easyproject', __FILE__))
|
@@ -1,23 +0,0 @@
|
|
1
|
-
Dir[File.dirname(__FILE__) + '/lib/<%= plugin_name_underscored %>/easy_patch/**/*.rb'].each {|file| require_dependency file }
|
2
|
-
Dir[File.dirname(__FILE__) + '/extra/easy_patch/**/*.rb'].each { |file| require_dependency file }
|
3
|
-
|
4
|
-
# this block is executed once just after Redmine is started
|
5
|
-
# means after all plugins are initialized
|
6
|
-
# it is place for plain requires, not require_dependency
|
7
|
-
# it should contain hooks, permissions - base class in Redmine is required thus is not reloaded
|
8
|
-
ActiveSupport.on_load(:easyproject, yield: true) do
|
9
|
-
|
10
|
-
require '<%= plugin_name_underscored %>/internals'
|
11
|
-
require '<%= plugin_name_underscored %>/hooks'
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
# this block is called every time rails are reloading code
|
16
|
-
# in development it means after each change in observed file
|
17
|
-
# in production it means once just after server has started
|
18
|
-
# in this block should be used require_dependency, but only if necessary.
|
19
|
-
# better is to place a class in file named by rails naming convency and let it be loaded automatically
|
20
|
-
# Here goes query registering, custom fields registering and so on
|
21
|
-
RedmineExtensions::Reloader.to_prepare do
|
22
|
-
|
23
|
-
end
|
File without changes
|
@@ -1,20 +0,0 @@
|
|
1
|
-
Redmine::Plugin.register :<%= plugin_name_underscored %> do
|
2
|
-
name '<%= plugin_pretty_name %>'
|
3
|
-
author ''
|
4
|
-
author_url ''
|
5
|
-
description ''
|
6
|
-
version '<%= Date.today.strftime('%Y') %>'
|
7
|
-
|
8
|
-
#into easy_settings goes available setting as a symbol key, default value as a value
|
9
|
-
settings easy_settings: { }
|
10
|
-
<% if easy_plugin %>
|
11
|
-
plugin_in_relative_subdirectory File.join('easyproject', 'easy_plugins')
|
12
|
-
<% end %>
|
13
|
-
end
|
14
|
-
|
15
|
-
<% unless easy_plugin %>
|
16
|
-
unless Redmine::Plugin.registered_plugins[:easy_extensions]
|
17
|
-
require_relative 'after_init'
|
18
|
-
end
|
19
|
-
|
20
|
-
<% end %>
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module <%= plugin_title %>
|
2
|
-
module IssuePatch
|
3
|
-
|
4
|
-
def self.included(base)
|
5
|
-
base.extend(ClassMethods)
|
6
|
-
base.send(:include, InstanceMethods)
|
7
|
-
|
8
|
-
base.class_eval do
|
9
|
-
|
10
|
-
alias_method_chain :to_s, :<%= plugin_name_underscored %>
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
module InstanceMethods
|
16
|
-
|
17
|
-
def to_s_with_<%= plugin_name_underscored %>
|
18
|
-
'issue'
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
module ClassMethods
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
RedmineExtensions::PatchManager.register_model_patch 'Issue', '<%= plugin_title %>::IssuePatch'
|