diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index 544ebf0ce..86132a93a 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -91,6 +91,7 @@ module Mobile desc '课程留言列表' params do optional :token, type: String + optional :page,type:Integer,desc:'页数' end get ':id/course_message' do cs = CommentService.new diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index b9e46daee..fbafd16e9 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -243,14 +243,7 @@ class ProjectsController < ApplicationController # Author lizanle # Description 项目动态展示方法,删除了不必要的代码 def show - # params[:login]为邮箱邀请用户加入,主要功能: - # 1、自动注册 - # 2、加入项目、创建角色 - # 3、用户得分 - if params[:mail] - Member.create(:role_ids => [4], :user_id => params[:user],:project_id => params[:id]) - UserGrade.create(:user_id =>params[:user], :project_id => params[:id]) - end + if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return end @@ -399,6 +392,26 @@ class ProjectsController < ApplicationController # by young # include CoursesHelper def member + # params[:login]为邮箱邀请用户加入,主要功能: + # 1、自动注册 + # 2、加入项目、创建角色 + # 3、用户得分 + if params[:mail] + user = User.find(params[:user_id]) + user.activate! + Member.create(:role_ids => [4], :user_id => params[:user_id],:project_id => params[:id]) + UserGrade.create(:user_id => params[:user_id], :project_id => params[:id]) + token = Token.get_token_from_user(user, 'autologin') + #user = User.try_to_autologin(token.value) + if user + start_user_session(user) + user.save + redirect_to project_member_path(params[:id]) + return + # account_ project_member_path(params[:id]) + flash[:notice] = l(:label_mail_invite_success) + end + end ## 有角色参数的才是课程,没有的就是项目 @render_file = 'project_member_list' # 判断是否课程 diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 432eec27b..20b855fd8 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class WelcomeController < ApplicationController + # layout "base_welcome" include ApplicationHelper include WelcomeHelper helper :project_score diff --git a/app/models/invite_list.rb b/app/models/invite_list.rb new file mode 100644 index 000000000..f1ba8546f --- /dev/null +++ b/app/models/invite_list.rb @@ -0,0 +1,5 @@ +class InviteList < ActiveRecord::Base + attr_accessible :project_id, :user_id + # belongs_to :user + # belongs_to :project +end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 2c3a94874..dbc5d3cff 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -60,8 +60,8 @@ class Mailer < ActionMailer::Base user = us.register_auto(login, @email, @password) User.current = user unless User.current.nil? @user = user - @token = Token.get_token_from_user(user, 'autologin') - @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value) + + @project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true) mail :to => email, :subject => @subject end @@ -72,8 +72,9 @@ class Mailer < ActionMailer::Base @invitor_name = "#{invitor.name}" @project_name = "#{project.name}" @user = user + @project = project @token = Token.get_token_from_user(user, 'autologin') - @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value) + @project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value) mail :to => email, :subject => @subject end diff --git a/app/models/project.rb b/app/models/project.rb index 47878dbec..bf94df248 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -67,7 +67,7 @@ class Project < ActiveRecord::Base has_many :student, :through => :students_for_courses, :source => :user has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy has_many :applied_projects - + # has_many :invite_lists # end #ADDED BY NIE diff --git a/app/models/user.rb b/app/models/user.rb index 7b232bf13..4c30012d7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -125,6 +125,10 @@ class User < Principal has_many :documents # 项目中关联的文档再次与人关联 # end + # 邮件邀请状态 + # has_many :invite_lists + # end + ######added by nie has_many :project_infos, :dependent => :destroy has_one :user_status, :dependent => :destroy diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb index a742d0eee..2464297da 100644 --- a/app/services/comment_service.rb +++ b/app/services/comment_service.rb @@ -94,7 +94,7 @@ class CommentService def course_messages params,current_user @course = ::Course.find(params[:id]) if (current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course))) - @jours = @course.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + @jours = @course.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC').page(params[:page] ||= 1).per(10) else raise '403' end diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 77cebe0b1..40275a29b 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -62,7 +62,7 @@ class UsersService else @user.password = "" end - @user = automatically_register(@user) + @user = automatically_register_lock(@user) if @user.id != nil ue = @user.user_extensions ||= UserExtensions.new ue.user_id = @user.id @@ -292,6 +292,7 @@ class UsersService jours end + # 所有的与我相关 def reply_my_messages params,current_user jours = my_personal_messages params,current_user jours1 = my_course_messages params,current_user diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index 10f23d4f2..61c774a95 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -1,9 +1,10 @@ -<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> +<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'form_course', :locals => {:f => f, :topic => @message} %>
  • - <%= l(:button_cancel) %> - +
    +
    <%= l(:button_cancel) %> + <%= l(:button_submit)%>
    diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index d7eb7c215..0d9d6a780 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -1,26 +1,29 @@ - - - -
    -

    - <% if User.current.language == "zh"%> - <%= h @board.name %> - <% else %> - <%= l(:project_module_boards) %> +
    +
    +

    + <% if User.current.language == "zh"%> + <%= h @board.name %> + <% else %> + <%= l(:project_module_boards) %> + <% end %> + +

    + <% if User.current.logged? %> + <%= l(:label_message_new) %> <% end %> - -

    - <%= l(:label_message_new) %> +
    +
    +
    + +
    -
    -
    -
      - <%= render :partial => 'course_new' %> -
    -
    <% if !User.current.logged?%>
    @@ -32,15 +35,19 @@

    讨论区共有<%= @topic_count %>个帖子

    <% if @topics.any? %> <% @topics.each do |topic| %> -
    +
    <%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %>
    - <% author = topic.author.to_s + ":" %> - <%= link_to author, user_path(topic.author), :class =>"talkmain_name fl " %> + <% author = topic.author.to_s %> +
    + <%= link_to author, user_path(topic.author), :class =>"talkmain_name fl ",:title=>author, + :style=>'max-width:60px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;' %> +
    +

      :

    -

      <%= h(topic.subject) %>

    +

      <%= h(topic.subject) %>

    <% if topic.course_editable_by?(User.current) %> - <%= l(:button_edit) %> <% end %> @@ -81,105 +88,85 @@ <%= l(:label_activity_time)%>:  <%= format_time topic.created_on %>
    - <%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %> + <%= l(:button_reply) %>
    - -
    - -
    - <% reply = Message.new(:subject => "RE: #{@message.subject}")%> - <% if !topic.locked? && authorize_for('messages', 'reply') %> - -
    - + <% end %> + <% replies_all = topic.children.includes(:author, :attachments, {:board => :project}). + reorder("#{Message.table_name}.created_on DESC").all %> + <% unless replies_all.empty? %> + <% replies_all_i = 0 %> +
    +
      + <% replies_all.each do |message| %> + <% replies_all_i=replies_all_i+1 %> +
    • + <%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class =>'Msg_pic' %> +
      + <%= link_to_user_header message.author,false,:class => 'fl c_orange ' %> +
      +
      <%= textAreailizable message,:content,:attachments => message.attachments %>
      + +
      + <%= format_time(message.created_on) %> + <%= link_to( + + l(:button_delete), + {:controller => 'messages', :action => 'destroy', :id => message.id, :board_id => message.board_id, :is_board => 'true'}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete), + :class => ' c_dblue fr' + ) if message.course_destroyable_by?(User.current) %> + <%= link_to( + l(:button_reply), + 'javascript:;', + :nhname =>'showbtn_child_reply', + :class => ' c_dblue fr', + :style => 'margin-right: 10px;', + :title => l(:button_reply)) if !topic.locked? && authorize_for('messages', 'reply') %> +
      +
      + +
    • + <% end %> +
    +
    + <%if topic.replies_count>2 %> + + <% end %> + <% end %> +
    +
    +
    + <% end %> <% else %>

    <%= l(:label_no_data) %>

    @@ -197,58 +184,80 @@ <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@course}: #{@board}") %> <% end %>
    +
    \ No newline at end of file diff --git a/app/views/boards/_edit.html.erb b/app/views/boards/_edit.html.erb index 562319e56..909689edd 100644 --- a/app/views/boards/_edit.html.erb +++ b/app/views/boards/_edit.html.erb @@ -12,6 +12,7 @@ } do |f| %> <%= render :partial => 'form_project', :locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %> +
    <%= l(:button_cancel) %> <%= l(:button_submit)%> <%#= link_to l(:button_cancel), board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "blue_btn grey_btn fl c_white" %> @@ -31,6 +32,7 @@ } do |f| %> <%= render :partial => 'form_course', :locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %> +
    <%= l(:button_cancel) %> <%= l(:button_submit)%> diff --git a/app/views/boards/_form_course.html.erb b/app/views/boards/_form_course.html.erb index cfef18f93..65e750b57 100644 --- a/app/views/boards/_form_course.html.erb +++ b/app/views/boards/_form_course.html.erb @@ -5,19 +5,19 @@
  • - <%= f.text_field :subject, { size: 60, id: "message_subject",:class=>"talk_input w585", :aa=>"subject" }.merge(extra_option) %> + <%= f.text_field :subject, { size: 60, id: "message_subject",:class=>"talk_input w585", :nhname=>'inputsubject' }.merge(extra_option) %> -

    +

  • <% else %>
  • - <%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}", onkeyup: "regexSubject('#{f.object.id}');",:class=>"talk_input w585", :aa=>"subject" }.merge(extra_option) %> + <%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}", onkeyup: "regexSubject('#{f.object.id}');",:class=>"talk_input w585", :nhname=>'inputsubject' }.merge(extra_option) %> -

    +

  • <% end %>
  • @@ -34,11 +34,11 @@
  • -
    +
    <% unless replying %> <% end %> - <%= text_area :quote,:quote,:style => 'display:none' %> + <%= text_area :quote,:quote,:style => 'display:none',:nhname=>"quote_input" %>
    <% if replying%> @@ -46,13 +46,14 @@ :width => '89%', :height => 300, :id => "message_content#{f.object.id}", - :aa => 'content', + :nhname => 'textarea', :onkeyup => "regexContent('#{f.object.id}');", :class => 'talk_text fl', :placeholder => "最多3000个汉字(或6000个英文字符)", :maxlength => 5000 %> <% else %> + <%= f.text_area :content, :width => '90%', :height => 300, @@ -61,14 +62,14 @@ :id => "message_content#{f.object.id}", :onkeyup => "regexContent('#{f.object.id}');", :class => 'talk_text fl', - :aa => 'content', + :nhname => 'textarea', :placeholder => "最多3000个汉字(或6000个英文字符)", :maxlength => 5000 %> <% end %>
    -

    +

  • diff --git a/app/views/boards/_form_project.html.erb b/app/views/boards/_form_project.html.erb index 5cf20a993..f6b41b53f 100644 --- a/app/views/boards/_form_project.html.erb +++ b/app/views/boards/_form_project.html.erb @@ -1,4 +1,3 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor-min" %> +<%= javascript_include_tag "/assets/kindeditor/kindeditor-min" %> + +<% if @project %> + <%= render :partial => 'project_show', locals: {project: @project} %> +<% elsif @course %> + <%= render :partial => 'course_show', locals: {course: @course} %> +<% end %> + - -<% if @project %> - <%= render :partial => 'project_show', locals: {project: @project} %> -<% elsif @course %> - <%= render :partial => 'course_show', locals: {course: @course} %> -<% end %> + \ No newline at end of file diff --git a/app/views/courses/homework.html.erb b/app/views/courses/homework.html.erb index 7b74351cd..32728adf0 100644 --- a/app/views/courses/homework.html.erb +++ b/app/views/courses/homework.html.erb @@ -31,7 +31,7 @@ <% end %>
    diff --git a/app/views/layouts/_user_project_list.html.erb b/app/views/layouts/_user_project_list.html.erb index c70086499..e38f9c4bd 100644 --- a/app/views/layouts/_user_project_list.html.erb +++ b/app/views/layouts/_user_project_list.html.erb @@ -2,13 +2,11 @@
  • <%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name} %>
  • -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index 439c5f7b2..483cabac5 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -12,7 +12,7 @@ <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= javascript_heads %> <%= javascript_include_tag "jquery.leanModal.min" %> -<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> +<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> <%= heads_for_theme %> <%= call_hook :view_layouts_base_html_head %> @@ -31,7 +31,7 @@
    <%=render :partial => 'layouts/base_footer'%> - + diff --git a/app/views/layouts/base_welcome.html.erb b/app/views/layouts/base_welcome.html.erb index d04f492ef..6d3b900c6 100644 --- a/app/views/layouts/base_welcome.html.erb +++ b/app/views/layouts/base_welcome.html.erb @@ -5,10 +5,9 @@ <%=h html_title %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> - <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= stylesheet_link_tag 'public', 'pleft', 'project', :media => 'all' %> + <%= javascript_include_tag "jquery.leanModal.min" %> - <%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> <%= csrf_meta_tag %> <%= favicon %> @@ -18,32 +17,26 @@ <%= yield :header_tags -%> - -
    -
    -
    - <%=render :partial => 'layouts/base_header'%> + +
    + <%= render :partial => 'layouts/new_header' %> +
    <%= render_flash_messages %> <%= yield %> <%= call_hook :view_layouts_base_content %>
    - <%=render :partial => 'layouts/base_footer'%> + <%=render :partial => 'layouts/new_footer'%>
    - -
    -
    <%= call_hook :view_layouts_base_body_bottom %> diff --git a/app/views/stores/index.html.erb b/app/views/stores/index.html.erb index 89405b8ab..6fab364b5 100644 --- a/app/views/stores/index.html.erb +++ b/app/views/stores/index.html.erb @@ -3,10 +3,10 @@ <% end %>
    -<% @attach_array.each do |k|%> +<% @attach_array.each_with_index do |k, index|%>

    - <%= @str_arr.shift %> + <%= @str_arr[index] %>

    @@ -24,7 +24,7 @@
    - <% if @str_arr.shift == @str_arr[2]%> + <% if index == 2%> <% k.each do |c1|%>
    @@ -94,4 +94,4 @@ } }); -<% html_title(l(:label_stores_index)) -%> \ No newline at end of file +<% html_title(l(:label_stores_index)) -%> diff --git a/app/views/welcome/_course_list.html.erb b/app/views/welcome/_course_list.html.erb index 111c0abb1..d51bcc8f7 100644 --- a/app/views/welcome/_course_list.html.erb +++ b/app/views/welcome/_course_list.html.erb @@ -25,7 +25,7 @@ <%= link_to course.school.name.try(:gsub, /(.+)$/, '\1'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %> <% end %> (<%= course.members.count %>人) - <% files_count = course.attachments.count %> + <% files_count = visable_attachemnts_incourse(course).count %> <% if files_count > 0%> (<%= link_to "#{files_count.to_s}份", course_files_path(course) %>公开资料) <% end %> diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 180b0322a..8ca078084 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -342,6 +342,7 @@ zh: label_invite_trustie_user_tips: "输入姓名、邮箱、昵称" label_user_role_null: 用户和角色不能留空! label_invite_project: 邀请您加入项目 + label_mail_invite_success: 您已成功加入项目! label_invite_success: 邀请成功 label_invite_members: 邀请用户 # diff --git a/db/migrate/20150528024616_create_invite_lists.rb b/db/migrate/20150528024616_create_invite_lists.rb new file mode 100644 index 000000000..222a3a3f8 --- /dev/null +++ b/db/migrate/20150528024616_create_invite_lists.rb @@ -0,0 +1,10 @@ +class CreateInviteLists < ActiveRecord::Migration + def change + create_table :invite_lists do |t| + t.integer :project_id + t.integer :user_id + + t.timestamps + end + end +end diff --git a/public/images/public_icon.png b/public/images/public_icon.png index 68be31f5d..1fa463e4e 100644 Binary files a/public/images/public_icon.png and b/public/images/public_icon.png differ diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 5333b91a7..d27895b03 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -19,7 +19,7 @@ a:hover.project_name{ color:#016f33;} a.project_txt02{ color:#0781b4; width:618px; display:block; float:left; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} a:hover.project_txt{ color:#066e9a;} .noline{ border-bottom:none;} -.news_description{max-height: 38px;overflow:hidden; } +.news_description{max-height: 360px;overflow:hidden; } .news_description_none{max-height: none;} a.news_foot{ border:1px solid #e8eef2; color: #929598; text-align:center; width:600px; height:20px; padding-top:3px; cursor:pointer;} a:hover.news_foot{ color:#787b7e; border:1px solid #d4d4d4;} diff --git a/spec/factories/invite_lists.rb b/spec/factories/invite_lists.rb new file mode 100644 index 000000000..c9ce0e826 --- /dev/null +++ b/spec/factories/invite_lists.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :invite_list do + project_id 1 +user_id 1 + end + +end diff --git a/spec/models/invite_list_spec.rb b/spec/models/invite_list_spec.rb new file mode 100644 index 000000000..8da327964 --- /dev/null +++ b/spec/models/invite_list_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe InviteList, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end