企业版模块

This commit is contained in:
huang 2015-01-30 14:11:35 +08:00
parent f7dbb24d35
commit d0a675f2b8
19 changed files with 294 additions and 168 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the Enterprises controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,6 @@
class EnterprisesController < ApplicationController
layout 'project_base'
def index
@enterprises = Project.find_by_sql("select enterprise_name from projects")
end
end

View File

@ -25,6 +25,17 @@ class WelcomeController < ApplicationController
before_filter :entry_select, :only => [:index]
def index
unless params[:enterprise].nil?
@enterprise = params[:enterprise]
@enterprise_projects = Project.find_by_sql(["select * from projects where enterprise_name =? ", @enterprise])
@e_count = @enterprise_projects.count
if @e_count < 10
part_count = 10 -@e_count
# @part_projects = find_all_hot_project part_count, order
@part_projects = find_miracle_project(part_count, 3,"score desc")
limit = 10 - @e_count
end
end
if @first_page.nil? || @first_page.sort_type.nil?
@projects = find_miracle_project(10, 3,"score desc")
else

View File

@ -0,0 +1,2 @@
module EnterprisesHelper
end

View File

@ -375,4 +375,8 @@ module ProjectsHelper
end
end
end
def get_part_projects e_count, t_count
end
end

View File

@ -6,7 +6,7 @@ class Course < ActiveRecord::Base
STATUS_CLOSED = 5
STATUS_ARCHIVED = 9
attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student
attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student, :enterprise_name
#belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier
belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher该方法通过tea_id来调用User表
belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school该方法通过school_id来调用School表

View File

@ -116,6 +116,7 @@ class Project < ActiveRecord::Base
validates_associated :repository, :wiki
# validates_length_of :description, :maximum => 255
validates_length_of :name, :maximum => 255
validates_length_of :enterprise_name, :maximum => 255
validates_length_of :homepage, :maximum => 255
validates_length_of :identifier, :in => 1..IDENTIFIER_MAX_LENGTH
# donwcase letters, digits, dashes but not digits only
@ -760,7 +761,8 @@ class Project < ActiveRecord::Base
'issue_custom_field_ids',
'project_type',
'dts_test',
'attachmenttype'
'attachmenttype',
'enterprise_name'

View File

@ -0,0 +1,25 @@
<div class="enterprise_all">
<p>
<%= link_to l(:label_all_enterprises) %>
<p>
<p>
<% if @enterprises.count == 0 %>
<h3><%= l(:label_enterprise_nil) %></h3>
<% else %>
<% @enterprises.each do |enterprise| %>
<% unless enterprise.enterprise_name.blank? %>
<ul>
<li>
<%= link_to enterprise.enterprise_name, home_path(:enterprise => enterprise.enterprise_name) %>
</li>
</ul>
<% end %>
<% end %>
<% end %>
</p>
</div>
<div style="clear: both"></div>
<div class="school-index">
<ul id="schoollist" style="line-height: 25px"></ul>
</div>
<% html_title(l(:label_school_all)) -%>

View File

@ -8,7 +8,7 @@
<p style="padding-right: 20px;">
<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
</p><!--by young-->
<p><%= f.text_field :enterprise_name, :size => 60, :style => "width:490px;" %></p>
<p style="display: none" ><%= f.text_field :identifier, :required => true, :size => 60, :style => "width:488px;", :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH,
value:"#{User.current.id.to_s + '_' +Time.now.to_s.gsub(' ','_').gsub(':','').gsub('+','')}" %>
<% unless @project.identifier_frozen? %>

View File

@ -0,0 +1,23 @@
<li style="overflow:hidden;word-break:break-all;height:100%;word-wrap: break-word;" class='<%= cycle("odd", "even") %>'>
<div style="float: left;">
<%= image_tag(get_project_avatar(project), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div style="float: left; margin-left: 10px; width: 380px;">
<% unless project.is_public %>
<span class="private_project"> <%= l(:label_private) %> </span>
<% end %>
<%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
(<%= link_to "#{projectCount(project)}人", project_member_path(project) ,:course =>'0' %>)
</div>
<div style=" float: left;margin:5px; margin-left: 10px; width: 380px;min-height: 42px;">
<span class='font_lighter' title ='<%= project.short_description%>'> <%=project.description.truncate(90, omission: '...')%> </span>
</div>
<div >
<%= content_tag "span", l(:label_project_score)+ ":" + red_project_scores(project).to_i.to_s,
:style => "cursor: pointer; display: inline-block; float: right; color: #ec6300;",
:title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度",
:class => "tooltip",
:id => "tooltip-#{project.id}" %>
</div>
</li>

View File

@ -1,5 +1,5 @@
<h1></h1>
<p id="errorExplanation">
<%= course_title%>
<%= course_title %>
</p>
<h1></h1>

View File

@ -2,24 +2,23 @@
<%= stylesheet_link_tag 'welcome' %>
<%= javascript_include_tag 'welcome' %>
<script type="text/javascript" language="javascript">
$(function(){
$(function() {
$("#main").find("a").attr("target", "_blank");
setCss();
});
//设置div居中
function setCss()
{
function setCss() {
var mainBar = $('#main-content-bar')[0];
var topHeight = mainBar.offsetHeight;
var welcomeLeft = $('#welcome_left')[0];
var leftHeight = welcomeLeft.offsetHeight;
var searchbar = $('#search-bar')[0];
var searchHeight = searchbar.offsetHeight;
welcomeLeft.style.marginTop = (topHeight - leftHeight)/2 + "px";
searchbar.style.marginTop = (topHeight - searchHeight)/2 + "px";
welcomeLeft.style.marginTop = (topHeight - leftHeight) / 2 + "px";
searchbar.style.marginTop = (topHeight - searchHeight) / 2 + "px";
//alert((topHeight - leftHeight)/2 );
}
// 给主页用户弹新页面
$(document).ready(function($) {
$("#loggedas").find("a").attr("target", "_blank");
@ -32,17 +31,27 @@
<div class="main-content-bar" id="main-content-bar">
<div style="float: left;padding-left:15px ">
<!-- <#%= image_tag(get_project_avatar(@first_page), size: "75x75") %> -->
<% if @enterprise.nil? %>
<% if get_avatar?(@first_page) %>
<%= image_tag(url_to_avatar(@first_page), width:@first_page.image_width,height: @first_page.image_height) %>
<% else %>
<%= image_tag '/images/transparent.png', width:@first_page.image_width,height: @first_page.image_height %>
<% end %>
<% else %>
<%= image_tag '/images/avatars/Project/0', width:@first_page.image_width,height: @first_page.image_height %>
<% end %>
</div>
<div class="welcome_left" id="welcome_left">
<% if @enterprise.nil? %>
<% unless @first_page.nil? %>
<%= @first_page.description.html_safe %>
<% end %>
<% else %>
<span class="font_welcome_school" style="color: #E8770D"> <%= link_to @enterprise, options={:action => 'index', :enterprise => @enterprise}, html_options={ :method => 'get', :style => "color: #E8770D"} %> </span>
<br/>
<span class="font_welcome_trustie"> <%= @first_page.title %> </span>
<% end %>
</div>
<div class="search-bar" id="search-bar">
<%= render :partial => "search_project", :locals => {:project_type => 0}%>
@ -51,16 +60,11 @@
</div>
</div>
<div style="clear:both"></div>
<div style="clear:both"></div>
<div id="J_Slide" class="d-p-index-box d-p-index-hot">
<h3 style="margin-left: 5px; color: #e8770d;">
<strong>
<%= l(:lable_hot_projects)%>
</strong>
</h3>
<span style="margin-top: -20px;float: right; display: block;">
<% if User.current.logged? %>
<h3 style="margin-left: 5px; color: #e8770d;"><strong> <%= l(:lable_hot_projects)%> </strong></h3>
<span style="margin-top: -20px;float: right; display: block;"> <% if User.current.logged? %>
<%= link_to(l(:label_project_new), {:controller => 'projects',
:action => 'new',
:course => 0,
@ -69,39 +73,34 @@
&nbsp;&nbsp;&nbsp;&nbsp;
<%= link_to l(:label_join_project), join_project_projects_path ,:remote => true, :class => 'icon icon-add' %>
&nbsp;&nbsp;&nbsp;&nbsp;
<% end %>
</span>
<% end %> </span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<!-- 如果企业版参数正确,这进入企业版页面 -->
<% if @enterprise.nil? %>
<% @projects.map do |project| %>
<li style="overflow:hidden;word-break:break-all;height:100%;word-wrap: break-word;" class='<%= cycle("odd", "even") %>'>
<div style="float: left;">
<%= image_tag(get_project_avatar(project), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div style="float: left; margin-left: 10px; width: 380px;">
<% unless project.is_public %>
<span class="private_project">
<%= l(:label_private) %>
</span>
<%= render :partial => 'hot_projects_list', :locals => {:project => project} %>
<% end; reset_cycle %>
<!-- 企业版项目 -->
<% else %>
<% if @e_count == 0 %>
<p id="errorExplanation"><%= l(:label_enterprise_tips) %></p>
<% @projects.map do |project| %>
<%= render :partial => 'hot_projects_list', :locals => {:project => project} %>
<% end; reset_cycle %>
<% elsif @e_count < 10 %>
<% @enterprise_projects.map do |project| %>
<%= render :partial => 'hot_projects_list', :locals => {:project => project} %>
<% end %>
<%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
(<%= link_to "#{projectCount(project)}人", project_member_path(project) ,:course =>'0' %>)
</div>
<div style=" float: left;margin:5px; margin-left: 10px; width: 380px;min-height: 42px;">
<span class='font_lighter' title ='<%=project.short_description%>'>
<%=project.description.truncate(90, omission: '...')%>
</span>
</div>
<div >
<%= content_tag "span", l(:label_project_score)+ ":" + red_project_scores(project).to_i.to_s,
:style => "cursor: pointer; display: inline-block; float: right; color: #ec6300;",
:title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度",
:class => "tooltip",
:id => "tooltip-#{project.id}" %>
</div>
</li>
<!--<%#end %> -->
<p id="errorExplanation"><%= l(:label_part_enterprise_tips) %></p>
<% @part_projects.map do |project| %>
<%= render :partial => 'hot_projects_list', :locals => {:project => project} %>
<% end %>
<% else %>
<% @part_projects.map do |project| %>
<%= render :partial => 'hot_projects_list', :locals => {:project => project} %>
<% end %>
<% end; reset_cycle %>
<% end; reset_cycle %>
</ul>
</div>
@ -109,55 +108,38 @@
<div id="J_Slide" class="d-p-index-box d-p-index-Dynamic">
<ul class="user-welcome-message-list">
<h3 style="color: rgb(21, 188, 207)">
<strong>
<%= l(:lable_user_active)%>
</strong>
</h3>
<h3 style="color: rgb(21, 188, 207)"><strong> <%= l(:lable_user_active)%> </strong></h3>
<div class="user-message-box-list" style="margin-top: 10px;">
<%activities = find_all_activities%>
<% activities = find_all_activities%>
<% activities.each do |event| %>
<li style="display: block;height:60px; padding-bottom: 4px;">
<div class="inner-right" style="float: left; height: 100%; ">
<%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %>
</div>
<div class="inner-right" style="float: right; width:86%; height: 100%; overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" >
<span style="color: green;">
<%= link_to event.event_author, (user_path(event.event_author) if event.event_author),
:style => "color:green;", :target => "_blank" %>
</span>
<span style="color: green;"> <%= link_to event.event_author, (user_path(event.event_author) if event.event_author),
:style => "color:green;", :target => "_blank" %> </span>
<%= show_user_content event %>
<p style="margin-top: 4px;">
<span style="color: rgb(172, 174, 177)">
<%= l(:field_updated_on) %>
<%= time_tag_welcome event.event_datetime %>前
</span>
<span style="color: rgb(172, 174, 177)"> <%= l(:field_updated_on) %>
<%= time_tag_welcome event.event_datetime %>前 </span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style="float: right; color: rgb(172, 174, 177);">
<%= show_event_reply event %>
</span>
<span style="float: right; color: rgb(172, 174, 177);"> <%= show_event_reply event %> </span>
</p>
</div>
</li>
<% end %>
</div>
</ul>
</div>
</div>
<div class="right" style="float: right; width: 48%; ">
<ul class="welcome-message-list">
<!--<%# cache 'forum_links' do %> -->
<div class="forum-topic" style="height: 25px; width: 98%; margin-left: 2px;">
<h3 style="color: rgb(21, 188, 207);">
<strong>
<%= l(:lable_bar_active)%>
</strong>
<%= link_to l(:label_my_question) , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
<%= link_to l(:label_my_feedback) , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
</h3>
<span style="margin-top: -30px;float: right; display: block;">
<%= link_to l(:label_more), forums_path %>
</span>
<h3 style="color: rgb(21, 188, 207);"><strong> <%= l(:lable_bar_active)%> </strong> <%= link_to l(:label_my_question) , newbie_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%>
<%= link_to l(:label_my_feedback) , suggestion_send_path, {:class => 'orangeButton idea_btn', :style => "color: #EEEEEE" }%> </h3>
<span style="margin-top: -30px;float: right; display: block;"> <%= link_to l(:label_more), forums_path %> </span>
</div>
<div class="welcome-box-list-new memo_activity">
<% topics = find_new_forum_topics(6) %>
@ -169,26 +151,19 @@
<%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url,title: topic.subject %>
</div>
<div class='memo_attr'>
<span class='memo_timestamp'>
<%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %>
</span>
<span class="memo_author">
<%= l(:label_question_sponsor)%>
<%= link_to topic.author.login.truncate(10, omission: '...'),user_path(topic.author),title: topic.author.login %>
</span>
<span class="memo_last_person">
<% unless (topic.last_reply.nil? || topic.last_reply.author.nil?) %>
<span class='memo_timestamp'> <%= "#{l(:label_updated_time, value: time_tag_welcome(topic_last_time topic))}".html_safe %> </span>
<span class="memo_author"> <%= l(:label_question_sponsor)%>
<%= link_to topic.author.login.truncate(10, omission: '...'),user_path(topic.author),title: topic.author.login %> </span>
<span class="memo_last_person"> <% unless (topic.last_reply.nil? || topic.last_reply.author.nil?) %>
<%= l(:label_final_reply)%>
<%=link_to topic.last_reply.author.login.truncate(10, omission: '...'),user_path(topic.last_reply.author),title: topic.last_reply.author.login%>
<% end %>
</span>
<span class="memo_reply">
<%= l(:label_reply)%>
(<%= link_to topic.try(:replies_count), topic.event_url %>)
</span>
<%= link_to topic.last_reply.author.login.truncate(10, omission: '...'),user_path(topic.last_reply.author),title: topic.last_reply.author.login%>
<% end %> </span>
<span class="memo_reply"> <%= l(:label_reply)%>
(<%= link_to topic.try(:replies_count), topic.event_url %>) </span>
</div>
</li>
<!--<%#end %> --> <!-- cache -->
<!--<%#end %> -->
<!-- cache -->
<% end %>
</div>
</ul>

View File

@ -275,6 +275,7 @@ zh:
label_course_closed_tips: "确定要%{desc}课程?"
# end
field_name: 名称
field_enterprise_name: 企业名
#added by huang
field_tea_name: 教师
field_couurse_time: 学时
@ -2313,3 +2314,12 @@ zh:
label_technical_support: 技术支持:
label_feedback: 意见反馈
# 项目企业模块
label_all_enterprises: 所有企业
label_my_enterprise: 我的企业
label_enterprise_tips: 暂时还没有该企业对应的项目,系统的其它项目您可能会感兴趣!
label_part_enterprise_tips: 系统的其它项目您可能也会感兴趣!
label_enterprise_nil: 改模块为最新上线模块,目前还未有项目关联到企业!
label_enterprises: 名企

View File

@ -26,6 +26,8 @@
# Example: :via => :get ====> :via => :get
RedmineApp::Application.routes.draw do
get "enterprises/index"
#match '/contests/:id/contestnotifications', :controller => 'contestnotifications', :action => 'index'
mount Mobile::API => '/api'
@ -388,6 +390,7 @@ RedmineApp::Application.routes.draw do
match '/statistics', :to => 'projects#statistics', :as => 'statistics', :via => :get
# match '/investor', :controller => 'projects', :action => 'investor', :as => 'investor', :via => :get
match '/homework', :to => 'projects#homework', :as => 'homework', :via => :get
match 'enterprise', :to => 'enterprises#index', :as => 'index', :via => :get
# match '/activity', :controller => 'activities', :action => 'index', :as => 'activity', :via => :get
# match '/repository', :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil, :as => 'repository', :via => :get

View File

@ -0,0 +1,5 @@
class AddEnterpriseNameToProjects < ActiveRecord::Migration
def change
add_column :projects, :enterprise_name, :string
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150123020615) do
ActiveRecord::Schema.define(:version => 20150128032421) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -925,6 +925,7 @@ ActiveRecord::Schema.define(:version => 20150123020615) do
t.integer "attachmenttype", :default => 1
t.integer "user_id"
t.integer "dts_test", :default => 0
t.string "enterprise_name"
end
add_index "projects", ["lft"], :name => "index_projects_on_lft"
@ -1069,6 +1070,14 @@ ActiveRecord::Schema.define(:version => 20150123020615) do
t.string "description"
end
create_table "social_groups", :force => true do |t|
t.string "name"
t.text "description"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "softapplications", :force => true do |t|
t.string "name"
t.text "description"
@ -1284,6 +1293,36 @@ ActiveRecord::Schema.define(:version => 20150123020615) do
add_index "versions", ["project_id"], :name => "versions_project_id"
add_index "versions", ["sharing"], :name => "index_versions_on_sharing"
create_table "voting_choices", :force => true do |t|
t.integer "poll_id", :null => false
t.string "text", :null => false
t.datetime "created_on", :null => false
t.integer "position", :default => 1
end
add_index "voting_choices", ["poll_id"], :name => "choices_poll_id"
create_table "voting_polls", :force => true do |t|
t.integer "project_id", :null => false
t.string "question", :null => false
t.datetime "created_on", :null => false
t.boolean "revote"
end
add_index "voting_polls", ["project_id"], :name => "polls_project_id"
create_table "voting_votes", :force => true do |t|
t.integer "user_id", :null => false
t.integer "poll_id", :null => false
t.integer "choice_id", :null => false
t.datetime "created_on", :null => false
end
add_index "voting_votes", ["choice_id"], :name => "votes_choice_id"
add_index "voting_votes", ["poll_id"], :name => "votes_poll_id"
add_index "voting_votes", ["user_id", "poll_id"], :name => "votes_user_poll_unique", :unique => true
add_index "voting_votes", ["user_id"], :name => "votes_user_id"
create_table "watchers", :force => true do |t|
t.string "watchable_type", :default => "", :null => false
t.integer "watchable_id", :default => 0, :null => false

View File

@ -9,6 +9,9 @@ h4, .wiki h3 {font-size: 13px;}
h4 {border-bottom: 1px dotted #bbb;}
/*huang*/
/*current position*/
.enterprise_all{
padding-left: 20px;
}
.course_ad{
position:absolute;
visibility:visible;

View File

@ -0,0 +1,12 @@
require 'spec_helper'
describe EnterprisesController do
describe "GET 'index'" do
it "returns http success" do
get 'index'
response.should be_success
end
end
end