FIX project setting revison

This commit is contained in:
Jasder 2019-11-12 17:44:47 +08:00
parent d37e026d68
commit f4890dfa25
3 changed files with 37 additions and 17 deletions

View File

@ -110,7 +110,7 @@ module ProjectsHelper
]
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
end
def sort_project(state, project_type)
content = ''.html_safe
case state
@ -129,8 +129,8 @@ module ProjectsHelper
content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0', :project_type => project_type)))
end
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")
end
# 判断我的项目中是否有重名项目
@ -352,12 +352,12 @@ module ProjectsHelper
when "attachment"
l :label_attachment
when "news"
l :label_news
l :label_news
else
""
""
end
end
def eventToLanguageCourse event_type, project
case event_type
when "issue-note"
@ -369,7 +369,7 @@ module ProjectsHelper
when "news"
project.project_type == 1 ? (l :label_notification) : (l :label_news)
else
""
""
end
end
@ -394,7 +394,7 @@ module ProjectsHelper
@projects_status = ProjectStatus.visible.where("project_statuses.project_type <> ? or project_statuses.project_type is null", 1)
@projects_status = @projects_status.reorder('grade').all.reverse
@projects = []
@projects_status.each do |obj|
@projects_status.each do |obj|
break if(@projects_status[10] == obj)
@projects << Project.visible.find_by_id("#{obj.project_id}")#where('id=:id', id: obj.project_id)
end
@ -411,12 +411,12 @@ module ProjectsHelper
limit = 10
#Project.find_by_sql("SELECT * FROM projects RIGHT OUTER JOIN (SELECT * FROM project_statuses ORDER BY grade DESC LIMIT #{limit} ) AS t ON projects.id = t.project_id ")
Project.find_by_sql("
SELECT p.id, p.name, p.description, p.identifier, t.project_id
SELECT p.id, p.name, p.description, p.identifier, t.project_id
FROM projects AS p RIGHT OUTER JOIN (
SELECT project_id,grade FROM project_statuses
SELECT project_id,grade FROM project_statuses
WHERE project_type = 0 ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ")
end
# 判断课程是否结束,快别用,这个定日子的方法有问题
def course_timeout? project
@ -674,4 +674,20 @@ module ProjectsHelper
return nil
end
end
def select_project_categories
ProjectCategory.desc_with_position.collect { |c| [c.name, c.id]}
end
def select_project_languages
ProjectLanguage.desc_with_position.collect { |pl| [pl.name, pl.id] }
end
def select_project_licenses
License.all.collect { |c| [c.name, c.id]}
end
def select_project_ignores
Ignore.all.collect { |c| [c.name, c.id]}
end
end

View File

@ -18,13 +18,13 @@
<li>
<span class="form_span requiredTag"><%= l(:lable_project_language)%></span>
<div class="flex1">
<%= f.select :project_language_id, (ProjectLanguage.desc_with_position.collect { |pl| [pl.name, pl.id] }),
<%= f.select :project_language_id, select_project_categories,
{:no_label => true, :required => true}, :class => "choose_100_35" %>
<p class="notice_form"><span id="project_language_notice" class="none">请选择项目语言</span></p>
</div>
<span class="form_span requiredTag ml50"><%= l(:lable_project_add_license) %></span>
<div class="flex1">
<%= f.select :license_id, options_for_select(License.all.collect { |c| [c.name, c.id]}, @project.license_id),
<%= f.select :license_id, options_for_select(select_project_licenses, @project.license_id),
{:required => true, :no_label => true}, multi: false, :class => "choose_100_35" %>
<p class="notice_form"><span id="project_tag_notice" class="none">请选择开源许可证</span></p>
</div>
@ -32,13 +32,13 @@
<li>
<span class="form_span requiredTag"><%= l(:lable_project_category) %></span>
<div class="flex1">
<%= f.select :project_category_id, options_for_select(ProjectCategory.desc_with_position.collect { |c| [c.name, c.id]}, @project.project_category_id),
<%= f.select :project_category_id, options_for_select(select_project_languages, @project.project_category_id),
{:required => true, :no_label => true}, multi: false, :class => "choose_100_35" %>
<p class="notice_form"><span id="project_type_notice" class="none">请选择项目语言</span></p>
<p class="notice_form"><span id="project_type_notice" class="none">请选择项目类别</span></p>
</div>
<span class="form_span requiredTag ml30"><%= l(:lable_project_add_gitignore) %></span>
<div class="flex1">
<%= f.select :ignore_id, options_for_select(Ignore.all.collect { |c| [c.name, c.id]}, @project.ignore_id),
<%= f.select :ignore_id, options_for_select(select_project_ignores, @project.ignore_id),
{:required => true, :no_label => true}, multi: false, :class => "choose_100_35" %>
<p class="notice_form"><span id="project_modal_notice" class="none">请选择开源许可证</span></p>
</div>

View File

@ -39,7 +39,11 @@
<% end %>
<li class="clear">
<label class="fl">&nbsp;语言&nbsp;&nbsp;</label>
<%= select_tag :language, options_for_select(["","java","python","c#"], :selected => "#{@project.language}"), :id => 'language', :class => "ml5", :style => "height: 28px;" %>
<%= select_tag 'project[project_language_id]', options_for_select(select_project_languages, :selected => "#{@project.project_language_id}"), :id => 'project_language', :class => "ml5", :style => "height: 28px;" %>
</li>
<li class="clear">
<label class="fl">&nbsp;类别&nbsp;&nbsp;</label>
<%= select_tag 'project[project_category_id]', options_for_select(select_project_categories, :selected => "#{@project.project_category_id}"), :id => 'project_category', :class => "ml5", :style => "height: 28px;" %>
</li>
<li class="clear">
<label class="fl">公开&nbsp;&nbsp;</label>