Commit 0a4c20a420745aa30f7fb7760063716aa228bff1
1 parent
5b668b51
Exists in
master
and in
5 other branches
Create profile editor page for software community into plugin
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Showing
3 changed files
with
156 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,40 @@ |
1 | +require_dependency 'profile_editor_controller' | |
2 | + | |
3 | +class ProfileEditorController | |
4 | + | |
5 | + before_filter :redirect_to_edit_software_community, :only => [:edit] | |
6 | + | |
7 | + def edit_software_community | |
8 | + @profile_data = profile | |
9 | + @possible_domains = profile.possible_domains | |
10 | + | |
11 | + edit_community_post_actions if request.post? | |
12 | + end | |
13 | + | |
14 | + protected | |
15 | + | |
16 | + | |
17 | + def redirect_to_edit_software_community | |
18 | + if profile.class == Community && profile.software? | |
19 | + redirect_to :action => 'edit_software_community' | |
20 | + end | |
21 | + end | |
22 | + | |
23 | + def edit_community_post_actions | |
24 | + params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash) | |
25 | + | |
26 | + Profile.transaction do | |
27 | + Image.transaction do | |
28 | + begin | |
29 | + @plugins.dispatch(:profile_editor_transaction_extras) | |
30 | + @profile_data.update_attributes!(params[:profile_data]) | |
31 | + | |
32 | + redirect_to :action => 'index', :profile => profile.identifier | |
33 | + rescue Exception => ex | |
34 | + profile.identifier = params[:profile] if profile.identifier.blank? | |
35 | + end | |
36 | + end | |
37 | + end | |
38 | + end | |
39 | + | |
40 | +end | ... | ... |
test/functional/profile_editor_controller_test.rb
... | ... | @@ -92,6 +92,15 @@ class ProfileEditorControllerTest < ActionController::TestCase |
92 | 92 | assert_equal 0, User.last.institutions.count |
93 | 93 | end |
94 | 94 | |
95 | + should "redirect to edit_software_community on edit community of software" do | |
96 | + software = create_software_info("Test Software") | |
97 | + | |
98 | + post :edit, :profile => software.community.identifier | |
99 | + | |
100 | + assert_redirected_to :controller => 'profile_editor', :action => 'edit_software_community' | |
101 | + end | |
102 | + | |
103 | + | |
95 | 104 | protected |
96 | 105 | |
97 | 106 | def create_basic_user |
... | ... | @@ -102,4 +111,23 @@ class ProfileEditorControllerTest < ActionController::TestCase |
102 | 111 | user.person.save! |
103 | 112 | user |
104 | 113 | end |
114 | + | |
115 | + def create_community name | |
116 | + community = fast_create(Community) | |
117 | + community.name = name | |
118 | + community.save | |
119 | + community | |
120 | + end | |
121 | + | |
122 | + def create_software_info name, finality = "", acronym = "" | |
123 | + community = create_community(name) | |
124 | + software_info = SoftwareInfo.new | |
125 | + software_info.community = community | |
126 | + software_info.finality = finality | |
127 | + software_info.acronym = acronym | |
128 | + software_info.public_software = true | |
129 | + software_info.save | |
130 | + software_info | |
131 | + end | |
132 | + | |
105 | 133 | end | ... | ... |
... | ... | @@ -0,0 +1,88 @@ |
1 | +<h1><%= _('Configure Community') %></h1> | |
2 | + | |
3 | +<%= javascript_include_tag 'deactivate_profile' %> | |
4 | +<%= error_messages_for :profile_data %> | |
5 | + | |
6 | +<%= labelled_form_for :profile_data, :html => { :id => 'profile-data', :multipart => true } do |f| %> | |
7 | + | |
8 | + <% if user.has_permission?('manage_environment_templates', profile.environment) %> | |
9 | + <div id="profile-is-template"> | |
10 | + <%= labelled_check_box(_('This profile is a template'), 'profile_data[is_template]', true, @profile.is_template) %> | |
11 | + </div> | |
12 | + <% end %> | |
13 | + | |
14 | + <%= render :partial => partial_for_class(@profile.class), :locals => { :f => f } %> | |
15 | + | |
16 | + <div id="profile_change_picture_title"> | |
17 | + <h2><%= _('Change picture') %></h2> | |
18 | + <span><%= unchangeable_privacy_field @profile %></span> | |
19 | + </div> | |
20 | + <div id="profile_change_picture"> | |
21 | + <%= f.fields_for :image_builder, @profile.image do |i| %> | |
22 | + <%= file_field_or_thumbnail(_('Image:'), @profile.image, i) %><%= _("Max size: %s (.jpg, .gif, .png)")% Image.max_size.to_humanreadable %> | |
23 | + <% end %> | |
24 | + </div> | |
25 | + | |
26 | + <h2><%= _('Privacy options') %></h2> | |
27 | + | |
28 | + <% if profile.person? %> | |
29 | + <div> | |
30 | + <%= labelled_radio_button _('Public — show my contents to all internet users'), 'profile_data[public_profile]', true, @profile.public_profile? %> | |
31 | + </div> | |
32 | + <div> | |
33 | + <%= labelled_radio_button _('Private — show my contents only to friends'), 'profile_data[public_profile]', false, !@profile.public_profile? %> | |
34 | + </div> | |
35 | + <% else %> | |
36 | + <div> | |
37 | + <%= labelled_radio_button _('Public — show content of this group to all internet users'), 'profile_data[public_profile]', true, @profile.public_profile? %> | |
38 | + </div> | |
39 | + <div> | |
40 | + <%= labelled_radio_button _('Private — show content of this group only to members'), 'profile_data[public_profile]', false, !@profile.public_profile? %> | |
41 | + </div> | |
42 | + <% end %> | |
43 | + | |
44 | + <% if environment.enabled?('allow_change_of_redirection_after_login') %> | |
45 | + <h2><%= _('Page to redirect after login') %></h2> | |
46 | + <%= select 'profile_data', 'redirection_after_login', Environment.login_redirection_options.map{|key,value|[value,key]}, { :selected => @profile.preferred_login_redirection} %> | |
47 | + <% end %> | |
48 | + | |
49 | + <h2><%= _('Translations') %></h2> | |
50 | + <%= labelled_check_box( | |
51 | + _('Automaticaly redirect the visitor to the article translated to his/her language'), | |
52 | + 'profile_data[redirect_l10n]', true, @profile.redirect_l10n | |
53 | + )%> | |
54 | + | |
55 | + <h2><%= _('Suggestions') %></h2> | |
56 | + <%= labelled_check_box( | |
57 | + _('Send me relationship suggestions by email'), | |
58 | + 'profile_data[email_suggestions]', true, @profile.email_suggestions | |
59 | + )%> | |
60 | + | |
61 | + <%= | |
62 | + @plugins.dispatch(:profile_editor_extras).map do |content| | |
63 | + content.kind_of?(Proc) ? self.instance_exec(&content) : content | |
64 | + end.join("\n") | |
65 | + %> | |
66 | + | |
67 | + <%= select_categories(:profile_data, _('Select the categories of your interest'), 2) %> | |
68 | + | |
69 | + <% button_bar do %> | |
70 | + <%= submit_button('save', _('Save'), :cancel => {:action => 'index'}) %> | |
71 | + <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> | |
72 | + <% end %> | |
73 | + | |
74 | + <% if user && user.has_permission?('destroy_profile', profile) %> | |
75 | + <% button_bar(:id => 'delete-profile') do %> | |
76 | + <%= button(:remove, _('Delete profile'), {:action => :destroy_profile}) %> | |
77 | + | |
78 | + <% if environment.admins.include?(current_person) %> | |
79 | + | |
80 | + <% if profile.visible? %> | |
81 | + <%= button(:remove, _('Deactivate profile'), {:action => :deactivate_profile, :id=>profile.id}, :id=>'deactivate_profile_button', :data => {:confirm=>_("Are you sure you want to deactivate this profile?")}) %> | |
82 | + <% else %> | |
83 | + <%= button(:add, _('Activate profile'), {:action => :activate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure you want to deactivate this profile?")}) %> | |
84 | + <% end %> | |
85 | + <% end %> | |
86 | + <% end %> | |
87 | + <% end %> | |
88 | +<% end %> | |
0 | 89 | \ No newline at end of file | ... | ... |