software_communities_plugin.rb
3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
class SoftwareCommunitiesPlugin < Noosfero::Plugin
include ActionView::Helpers::TagHelper
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::FormOptionsHelper
include ActionView::Helpers::JavaScriptHelper
include ActionView::Helpers::AssetTagHelper
include FormsHelper
include ActionView::Helpers
include ActionDispatch::Routing
include Rails.application.routes.url_helpers
def self.plugin_name
'SoftwareCommunitiesPlugin'
end
def self.plugin_description
_('Add Public Software and MPOG features.')
end
def profile_tabs
if context.profile.community?
return profile_tabs_software if context.profile.software?
end
end
def control_panel_buttons
if context.profile.software?
return software_info_button
elsif context.profile.person?
return create_new_software_button
end
end
def self.extra_blocks
{
SoftwaresBlock => { :type => [Environment, Person] },
SoftwareInformationBlock => { :type => [Community] },
DownloadBlock => { :type => [Community] },
RepositoryBlock => { :type => [Community] },
CategoriesAndTagsBlock => { :type => [Community] },
CategoriesSoftwareBlock => { :type => [Environment] },
SearchCatalogBlock => { :type => [Environment] }
}
end
def stylesheet?
true
end
def js_files
%w(
vendor/jquery.maskedinput.min.js
vendor/modulejs-1.5.0.min.js
vendor/jquery.js
lib/noosfero-root.js
lib/select-element.js
lib/select-field-choices.js
lib/auto-complete.js
lib/software-catalog-component.js
views/control-panel.js
views/edit-software.js
views/new-software.js
views/search-software-catalog.js
views/profile-tabs-software.js
views/new-community.js
blocks/software-download.js
initializer.js
app.js
)
end
# FIXME - if in error log apears has_permission?, try to use this method
def has_permission?(person, permission, target)
person.has_permission_without_plugins?(permission, target)
end
protected
def software_info_transaction
SoftwareInfo.transaction do
context.profile.
software_info.
update_attributes!(context.params[:software_info])
end
end
def license_transaction
license = LicenseInfo.find(context.params[:version])
context.profile.software_info.license_info = license
context.profile.software_info.save!
end
private
def software_info_button
{
:title => _('Software Info'),
:icon => 'edit-profile-group control-panel-software-link',
:url => {
:controller => 'software_communities_plugin_myprofile',
:action => 'edit_software'
}
}
end
def create_new_software_button
{
:title => _('Create a new software'),
:icon => 'design-editor',
:url => {
:controller => 'software_communities_plugin_myprofile',
:action => 'new_software'
}
}
end
def profile_tabs_software
{ :title => _('Software'),
:id => 'software-fields',
:content => Proc::new do render :partial => 'profile/software_tab' end,
:start => true }
end
end