Commit 60587181e665ecdb1dc39ed4c3d661d2da166e08
Committed by
Alessandro Palmeira
1 parent
1bf2c661
Exists in
master
and in
29 other branches
[Mezuro] editing a repository of a project
Showing
2 changed files
with
69 additions
and
1 deletions
Show diff stats
plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
@@ -26,7 +26,33 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | @@ -26,7 +26,33 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController | ||
26 | redirect_to_error_page repository.errors[0].message | 26 | redirect_to_error_page repository.errors[0].message |
27 | end | 27 | end |
28 | end | 28 | end |
29 | - | 29 | + |
30 | + def edit | ||
31 | + @project_content = profile.articles.find(params[:id]) | ||
32 | + | ||
33 | + @repository_types = Kalibro::Repository.repository_types | ||
34 | + | ||
35 | + configurations = Kalibro::Configuration.all | ||
36 | + configurations = [] if (configurations.nil?) | ||
37 | + @configuration_select = configurations.map do |configuration| | ||
38 | + [configuration.name,configuration.id] | ||
39 | + end | ||
40 | + @repository = @project_content.repositories.select{ |repository| repository.id == params[:repository_id].to_s }.first | ||
41 | + end | ||
42 | + | ||
43 | + def update | ||
44 | + project_content = profile.articles.find(params[:id]) | ||
45 | + | ||
46 | + repository = Kalibro::Repository.new( params[:repository] ) | ||
47 | + repository.save(project_content.project_id) | ||
48 | + | ||
49 | + if( repository.errors.empty? ) | ||
50 | + redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}" | ||
51 | + else | ||
52 | + redirect_to_error_page repository.errors[0].message | ||
53 | + end | ||
54 | + end | ||
55 | + | ||
30 | def show | 56 | def show |
31 | project_content = profile.articles.find(params[:id]) | 57 | project_content = profile.articles.find(params[:id]) |
32 | @project_name = project_content.name | 58 | @project_name = project_content.name |
plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb
0 → 100644
@@ -0,0 +1,42 @@ | @@ -0,0 +1,42 @@ | ||
1 | +<h2><%= @project_content.name %> Project</h2> | ||
2 | + | ||
3 | +<% form_for :repository, :url => {:action =>"update", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> | ||
4 | + <%= hidden_field_tag :id, @project_content.id %> | ||
5 | + | ||
6 | + <%= f.hidden_field :id%> | ||
7 | + <p> | ||
8 | + <%= f.label :name, "Name:" %> | ||
9 | + <%= f.text_field :name %> | ||
10 | + </p> | ||
11 | + <p> | ||
12 | + <%= f.label :description, "Description:" %> | ||
13 | + <%= f.text_field :description %> | ||
14 | + </p> | ||
15 | + | ||
16 | + <%= required labelled_form_field _('License'), | ||
17 | + f.select(:license, MezuroPlugin::Helpers::ContentViewerHelper.create_license_options) %><br/> | ||
18 | + <p> | ||
19 | + | ||
20 | + <p> | ||
21 | + <%= f.label :process_period, "Process Period:" %> | ||
22 | + <%= f.select(:process_period, MezuroPlugin::Helpers::ContentViewerHelper.create_periodicity_options) %> | ||
23 | + </p> | ||
24 | + <%= f.label :type, "Type:" %> | ||
25 | + <%= f.select :type, @repository_types%> | ||
26 | + </p> | ||
27 | + | ||
28 | + <p> | ||
29 | + <%= f.label :address, "Address:" %> | ||
30 | + <%= f.text_field :address%> | ||
31 | + </p> | ||
32 | + | ||
33 | + </p> | ||
34 | + <%= f.label :configuration_id, "Configuration:" %> | ||
35 | + <%= f.select :configuration_id, @configuration_select, :selected => @repository.configuration_id.to_i %> | ||
36 | + </p> | ||
37 | + | ||
38 | + <p> | ||
39 | + <%= f.submit "Add" %> | ||
40 | + </p> | ||
41 | + | ||
42 | +<% end %> |