项目base功能添加

This commit is contained in:
huang 2016-09-23 10:36:47 +08:00
parent 29b2a257c7
commit a8acb4a6cb
6 changed files with 59 additions and 27 deletions

View File

@ -361,8 +361,8 @@ module WatchersHelper
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort))
method = watched ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method,
:class => "pr_join_a" ,:id=>id
end
:class => "sy_btn_pink mr5" ,:id=>id
end
# 申请加入项目
def join_in_project_link(project, user, options=[])
@ -372,9 +372,9 @@ module WatchersHelper
method = 'post'
@applied_flag = project.instance_of?(Project)
if applied
link = "<a class ='pr_join_a'>#{text}</a>"
link = "<a class ='sy_btn_pink mr5'>#{text}</a>"
else
link = link_to(text, url, :remote => true, :method => method, :id => "#{project.id}", :class => "pr_join_a")
link = link_to(text, url, :remote => true, :method => method, :id => "#{project.id}", :class => "sy_btn_pink mr5")
end
link.html_safe
# if applied

View File

@ -305,6 +305,11 @@ class Project < ActiveRecord::Base
errors[:identifier].blank? && !(new_record? || identifier.blank?)
end
# returns project's creater
def creater
User.find(self.user_id).try(:show_name)
end
# returns latest created projects
# non public projects will be returned only if user is a member of those
def self.latest(user=nil, count=5)

View File

@ -1,21 +1,48 @@
<div class="sy_class_infobox mb10 clear">
<div class="sy_class_logo fl"><img src="images/project/logo_pro.jpg" width="110" height="110" alt="班级logo" /></div>
<div class="sy_class_id fl"><p>邀请码<br /><span class="sy_corange">Y7AUZ</span></p></div>
<div class="sy_class_logo fl">
<div class="pr" style="width: 110px; height:110px;">
<% if User.current.logged? && (User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project) || User.current.admin?) %>
<%=link_to image_tag(url_to_avatar(@project), width:"110", height: "110", :id => 'nh_source_tx'), my_clear_user_avatar_temp_path(:course => @project.id), :remote => true%>
<div class="homepageEditProfile undis">
<%=link_to '', my_clear_user_avatar_temp_path(:project => @project.id), :class => 'homepageEditProfileIcon', :title => '点击编辑头像', :remote => true %>
</div>
<% else %>
<%= image_tag(url_to_avatar(@project), :width => "110", :height => "110", :alt => "项目logo") %>
<% end %>
</div>
</div>
<div class="sy_class_id fl"><p><%= l(:label_project_ivite_code)%><br /><span class="sy_corange"><%= (User.current.member_of?(@project) || User.current.admin?) ? @project.invite_code : "******" %></span></p></div>
<div class="sy_class_info fl ml15">
<div class="sy_class_titbox clear">
<h3 class="fl sy_class_title"><a href="javascript:void(0);"class="mr5 c_dark">尹刚尹刚尹刚尹</a>/<a href="javascript:void(0);"class=" ml5 c_dark">Trustie ForgeTrustie ForgeTrustie ForgeTrustie ForgeTrustie ForgeTrustie ForgeTrustie ForgeTrustie ForgeTrustie ForgeTrustie ForgeTrustie ForgeTrustie ForgeTrustie Forge</a></h3><span class="sy_new_orange fl ml10 mt5">私有</span>
<h3 class="fl sy_class_title">
<a href="javascript:void(0);"class="mr5 c_dark"><%= @project.creater %></a>/
<a href="javascript:void(0);"class=" ml5 c_dark"><%= @project.name %></a>
</h3>
<span class="sy_new_orange fl ml10 mt5"><%= @project.is_public? ? l(:label_public) : l(:label_private) %></span>
</div>
<p class="sy_cgrey">
<span class=" mr15">项目评分:<a href="javascript:void(0);" class="sy_cblue">123</a></span>
<span class=" mr15">浏览:<a href="javascript:void(0);" class="sy_corange">123</a></span>
<span class=" mr15">关注:<a href="javascript:void(0);" class="sy_corange">123</a></span>
<span class=" mr15">成员:<a href="javascript:void(0);" class="sy_corange">123</a></span>
<span class=" mr15">项目评分:
<% if @project.project_type == 0 %>
<% unless static_project_score(@project.project_score) == 0 %>
<span class="fb f14 "><%= l(:label_project_score)%> :</span>
<%= link_to(format("%.2f" ,static_project_score(@project.project_score)).to_i,
{:controller => 'projects',
:action => 'show_projects_score',
:remote => true,
:id => @project.id}, :class => "sy_cblue" ) %>
<% end %>
<% end %>
</span>
<span class=" mr15">浏览:<a class="sy_corange"><%= @project.visits.to_i %></a></span>
<span class=" mr15"><%= l(:label_user_watcher) %>: <%= link_to "#{@project.watcher_users.count}", {:controller=>"projects", :action=>"watcherlist", :id => @project.id}, :class => 'sy_corange' %></span>
<span class=" mr15"><%= l(:label_member) %>: <%= link_to "#{@project.members.count}", project_member_path(@project), :class => 'sy_corange', :id => 'project_members_number' %></span>
</p>
<div class="mt15 clear">
<a href="javascript:void(0);" class="sy_btn_pink mr5" > +关注</a>
<a href="javascript:void(0);" class="sy_btn_blue mr5" > +加入</a>
<a href="javascript:void(0);" class="sy_btn_grey mr5" > 退出</a>
<a href="javascript:void(0);" class="sy_btn_blue mr5" > 配置</a>
<% text = @project.project_new_type == 1 ? l(:label_development_team) : (@project.project_new_type == 2 ? l(:label_research_group) : l(:label_friend_organization))%>
<% typeclass = @project.project_new_type == 1 ? "pr_kafa" : (@project.project_new_type == 2 ? "pr_keyan" : "pr_friend")%>
<%= render 'layouts/join_exit_project',{:text => text, :typeclass => typeclass} %>
</div>
</div>
<div class="cl"></div>

View File

@ -1,19 +1,18 @@
<div class="pr_info_join fl">
<!--关注:非项目成员-->
<div id="join_in_project_applied">
<%= render :partial => "projects/applied_status" %>
</div>
<%= render :partial => "projects/applied_status" %>
<!--配置项目-->
<% if User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project) %>
<%= link_to "<span class='pr_setting'></span>#{l(:button_configure)}".html_safe, settings_project_path(@project), :class => "pr_join_a" %>
<%= link_to "#{l(:button_configure)}", settings_project_path(@project), :class => "sy_btn_blue mr5" %>
<% end %>
<!--项目类型-->
<% if (User.current.login? && User.current.member_of?(@project) && Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.to_s.include?("Manager")) || User.current.admin? %>
<%= link_to "<span class='#{typeclass}'></span>#{text}".html_safe,"javascript:void(0)" ,:onClick => "show_window();", :class => "pr_join_a",:id => "setting_project_type"%>
<% end %>
<!--<%# if (User.current.login? && User.current.member_of?(@project) && Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.to_s.include?("Manager")) || User.current.admin? %>-->
<!--<%#= link_to "<span class='#{typeclass}'></span>#{text}".html_safe,"javascript:void(0)" ,:onClick => "show_window();", :class => "pr_join_a",:id => "setting_project_type"%>-->
<!--<%# end %>-->
<!--退出项目-->
<% if (User.current.member_of? @project) && User.current.login? && !User.current.admin &&
!Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.to_s.include?("Manager") %>
<%= exit_project_link(@project) %>
<% end %>
</div>

View File

@ -4,6 +4,7 @@
<% if AppliedProject.where(:user_id => User.current, :project_id => @project_id).first.nil? %>
<%= join_in_project_link(@project, User.current) %>
<% else %>
等待审批
<a class="sy_btn_blue mr5">等待审批</a>
<% end %>
<% end %>
<% end %>

View File

@ -51,7 +51,7 @@ zh:
label_project_ivite_code: "邀请码:"
label_agree_join_project: 同意加入
label_apply_project: "+申请加入"
label_apply_project: "+加入"
label_button_following: "+添加关注"
label_exit_project: 退出项目
label_apply_project_waiting: 已处理申请,请等待管理员审核