commit
d7ed4a985b
@ -0,0 +1,18 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Homeworkscore < Grape::Entity
|
||||
include Redmine::I18n
|
||||
include ApplicationHelper
|
||||
def self.homeworkscore_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
f[field]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
homeworkscore_expose :name
|
||||
homeworkscore_expose :score
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,34 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Member < Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.member_expose(f)
|
||||
expose f do |u,opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
elsif u.is_a?(::Member)
|
||||
if u.respond_to?(f)
|
||||
u.send(f)
|
||||
else
|
||||
case f
|
||||
when :student_id
|
||||
u.user.user_extensions.student_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a?(::Member)
|
||||
c.user
|
||||
end
|
||||
end
|
||||
member_expose :student_id
|
||||
member_expose :score
|
||||
member_expose :id
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,42 @@
|
||||
class DiscussDemosController < ApplicationController
|
||||
def index
|
||||
|
||||
@discuss_demo_list = DiscussDemo.where("body is not null").order("created_at desc").page(params[:page] || 1).per(10)
|
||||
end
|
||||
|
||||
def new
|
||||
@discuss_demo = DiscussDemo.create
|
||||
@discuss_demo.save!
|
||||
@discuss_demo
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
@discuss_demo = DiscussDemo.find(params[:id])
|
||||
@discuss_demo.update_attributes(:title => params[:discuss_demo][:title],:body => params[:discuss_demo][:body])
|
||||
redirect_to :controller=> 'discuss_demos',:action => 'show',:id => params[:id]
|
||||
end
|
||||
|
||||
def delete
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
asset = Kindeditor::Asset.find_by_owner_id(params[:id])
|
||||
if !asset.nil?
|
||||
filepath = File.join(Rails.root,"public","files","uploads",
|
||||
asset[:created_at].to_s.gsub("+0800","").to_datetime.strftime("%Y%m").to_s,
|
||||
asset[:asset].to_s)
|
||||
File.delete(filepath) if File.exist?filepath
|
||||
end
|
||||
DiscussDemo.destroy(params[:id])
|
||||
redirect_to :controller=> 'discuss_demos',:action => 'index'
|
||||
end
|
||||
|
||||
def show
|
||||
@discuss_demo = DiscussDemo.find(params[:id])
|
||||
end
|
||||
end
|
@ -0,0 +1,25 @@
|
||||
#coding=utf-8
|
||||
#
|
||||
|
||||
class DestroyRepositoryTask
|
||||
def destroy(user_id, rep_id)
|
||||
user = User.find(user_id)
|
||||
repository = Repository.find(rep_id)
|
||||
|
||||
Rails.logger.info "start delete repository #{user} #{repository}"
|
||||
@root_path=RepositoriesHelper::ROOT_PATH
|
||||
@repo_name=user.login.to_s+"_"+repository.identifier.to_s
|
||||
@repository_name=user.login.to_s+"/"+repository.identifier.to_s+".git"
|
||||
@middle=user.login.to_s+"_"+repository.identifier.to_s+"-write:"
|
||||
repository.destroy
|
||||
if(repository.type=="Repository::Git")
|
||||
Rails.logger.info "destory the repository value"+"root path"+@root_path+"repo_name"+@repo_name+
|
||||
"repository_name"+@repository_name+"user group"+@middle
|
||||
system "sed -i /"+@repo_name+"/{d} "+@root_path+"htdocs/user.passwd"
|
||||
system "sed -i /"+@middle+"/{d} "+@root_path+"htdocs/group.passwd"
|
||||
system "rm -r "+@root_path+"htdocs/"+@repository_name
|
||||
end
|
||||
end
|
||||
|
||||
handle_asynchronously :destroy,:queue => 'repository'
|
||||
end
|
@ -0,0 +1,18 @@
|
||||
<div style="font-weight:normal;">
|
||||
<% for attachment in attachments %>
|
||||
<div title="<%= attachment.filename%>" id = "attachment_" style="max-width: 300px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;float: left;">
|
||||
<%= link_to_short_attachment attachment, :class => 'link_file', :download => true, :length => 100 -%>
|
||||
</div>
|
||||
<% if attachment.is_text? %>
|
||||
<div style="float: left;">
|
||||
<%= link_to image_tag('magnifier.png'),
|
||||
{:controller => 'attachments',
|
||||
:action => 'show',
|
||||
:id => attachment,
|
||||
:filename => attachment.filename},
|
||||
:target => "_blank"%>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</div>
|
@ -1,8 +1,26 @@
|
||||
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
||||
var count=$('#attachments_fields>span').length;
|
||||
if(count<=0){
|
||||
$("#upload_file_count").text(<%= l(:label_no_file_uploaded)%>);
|
||||
var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>');
|
||||
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
|
||||
var containerid=$('.remove-upload',attachment_html_obj).data('containerid');
|
||||
if(containerid==undefined){
|
||||
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
||||
var count=$('#attachments_fields>span').length;
|
||||
if(count<=0){
|
||||
$("#upload_file_count").text('<%= l(:label_no_file_uploaded)%>');
|
||||
$(".remove_all").remove();
|
||||
}else{
|
||||
$("#upload_file_count").html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传");
|
||||
}
|
||||
}else{
|
||||
$("#upload_file_count").html("已上传"+"<span id=\"count\">"+count+"</span>"+"个文件");
|
||||
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
||||
var count=$('#attachments_fields'+containerid+'>span').length;
|
||||
if(count<=0){
|
||||
$('#upload_file_count'+containerid).text('<%= l(:label_no_file_uploaded)%>');
|
||||
var remove_all_html_obj = $(".remove_all").filter(function(index){
|
||||
return $(this).data('containerid')==containerid;
|
||||
});
|
||||
remove_all_html_obj.remove();
|
||||
}else{
|
||||
$('#upload_file_count'+containerid).html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传");
|
||||
}
|
||||
}
|
||||
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
|
@ -0,0 +1,66 @@
|
||||
<style type="text/css">
|
||||
#preview{width:360px;height:360px;border:1px solid #000;overflow:hidden;}
|
||||
#imghead {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
function previewImage(file)
|
||||
{
|
||||
var MAXWIDTH = 360;
|
||||
var MAXHEIGHT = 360;
|
||||
var div = document.getElementById('preview');
|
||||
if (file.files && file.files[0])
|
||||
{
|
||||
div.innerHTML = '<img id=imghead>';
|
||||
var img = document.getElementById('imghead');
|
||||
img.onload = function(){
|
||||
var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
|
||||
img.width = rect.width;
|
||||
img.height = rect.height;
|
||||
img.style.marginLeft = rect.left+'px';
|
||||
img.style.marginTop = rect.top+'px';
|
||||
}
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(evt){img.src = evt.target.result;}
|
||||
reader.readAsDataURL(file.files[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
|
||||
file.select();
|
||||
var src = document.selection.createRange().text;
|
||||
div.innerHTML = '<img id=imghead>';
|
||||
var img = document.getElementById('imghead');
|
||||
img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
|
||||
var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
|
||||
status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
|
||||
div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;margin-left:"+rect.left+"px;"+sFilter+src+"\"'></div>";
|
||||
}
|
||||
}
|
||||
function clacImgZoomParam( maxWidth, maxHeight, width, height ){
|
||||
var param = {top:0, left:0, width:width, height:height};
|
||||
if( width>maxWidth || height>maxHeight )
|
||||
{
|
||||
rateWidth = width / maxWidth;
|
||||
rateHeight = height / maxHeight;
|
||||
|
||||
if( rateWidth > rateHeight )
|
||||
{
|
||||
param.width = maxWidth;
|
||||
param.height = Math.round(height / rateWidth);
|
||||
}else
|
||||
{
|
||||
param.width = Math.round(width / rateHeight);
|
||||
param.height = maxHeight;
|
||||
}
|
||||
}
|
||||
|
||||
param.left = Math.round((maxWidth - param.width) / 2);
|
||||
param.top = Math.round((maxHeight - param.height) / 2);
|
||||
return param;
|
||||
}
|
||||
</script>
|
||||
<div id="preview">
|
||||
<img id="imghead" width=100 height=100 border=0 src="file:///C:/Users/whimlex/Downloads/1.jpg">
|
||||
</div>
|
||||
<br/>
|
||||
<input type="file" onchange="previewImage(this)" />
|
@ -1,4 +1,4 @@
|
||||
var imgSpan = $('#avatar_image');
|
||||
var imgSpan = jQuery('#avatar_image');
|
||||
|
||||
imgSpan.attr({"src":'<%= @urlfile.to_s << "?" << Time.now.to_s%>'});
|
||||
imgSpan.attr({"src":'<%= "#{@urlfile.to_s}?#{Time.now.to_i}" %>'});
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||
|
||||
<%= render :partial => 'form_course', :locals => {:f => f, :topic => @message} %>
|
||||
<li>
|
||||
<a href="javascript:void(0)" onclick="show_newtalk();" class="grey_btn fr ml10"><%= l(:button_cancel) %></a>
|
||||
<a href="#" onclick="submitProjectsBoard('<%= @message.id %>')" class="blue_btn fr " style="margin-left: 55px"><%= l(:button_submit)%></a>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<% end %>
|
@ -0,0 +1,43 @@
|
||||
|
||||
<% if topic.project %>
|
||||
<%#= board_breadcrumb(@message) %>
|
||||
<!--<h3><%#= avatar(@topic.author, :size => "24") %><span style = "width:100%;word-break:break-all;word-wrap: break-word;"><%#=h @topic.subject %></span></h3>-->
|
||||
<div class="talk_new ml15">
|
||||
<ul>
|
||||
<%= form_for topic, { :as => :message,
|
||||
:url => {:controller => 'messages',:action => 'edit', :is_board => 'true',:id => topic.id, :board_id => topic.board_id},
|
||||
:html => {:multipart => true,
|
||||
:id => 'message-form' + topic.id.to_s,
|
||||
:method => :post}
|
||||
} do |f| %>
|
||||
<%= render :partial => 'form_project',
|
||||
:locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %>
|
||||
<a href="javascript:void(0)" onclick="submitProjectsBoard('<%= topic.id%>');" class="blue_btn fl c_white" ><%= l(:button_submit)%></a>
|
||||
<a href="javascript:void(0)" onclick="show_newtalk1('#about_newtalk<%= topic.id%>');" class="blue_btn grey_btn fl c_white"><%= l(:button_cancel) %></a>
|
||||
<%#= 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" %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<% elsif topic.course %>
|
||||
<%#= course_board_breadcrumb(@message) %>
|
||||
<div class="talk_new ml15">
|
||||
<ul>
|
||||
<%= form_for topic, {
|
||||
:as => :message,
|
||||
:url => {:controller => 'messages',:action => 'edit', :is_board => 'true',:id => topic.id, :board_id => topic.board_id},
|
||||
:html => {:multipart => true,
|
||||
:id => 'message-form' + topic.id.to_s,
|
||||
:method => :post}
|
||||
} do |f| %>
|
||||
<%= render :partial => 'form_course',
|
||||
:locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %>
|
||||
<a href="javascript:void(0)" onclick="submitProjectsBoard('<%= topic.id%>');"class="blue_btn fl c_white"><%= l(:button_submit)%></a>
|
||||
<a href="javascript:void(0)" onclick="show_newtalk1('#about_newtalk<%= topic.id%>');" class="blue_btn grey_btn fl c_white"><%= l(:button_cancel) %></a>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
<div id="preview" class="wiki"></div>
|
@ -0,0 +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| %>
|
||||
|
||||
<%= render :partial => 'form_project', :locals => {:f => f, :topic => @message} %>
|
||||
<li>
|
||||
<a href="javascript:void(0)" onclick="show_newtalk();" class="grey_btn fr ml10"><%= l(:button_cancel) %></a>
|
||||
|
||||
<a href="#" onclick="submitProjectsBoard('<%= @message.id %>')" class="blue_btn fr " style="margin-left: 55px"><%= l(:button_submit)%></a>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<% end %>
|
@ -0,0 +1,39 @@
|
||||
<% delete_allowed = User.current.allowed_to?(:manage_files, course) %>
|
||||
<% if file.is_public? || User.current.member_of_course?(course) %>
|
||||
<div class="re_con_box" id="container_files_<%= file.id %>">
|
||||
<div class="">
|
||||
<%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s,:class => "c_dblue f_14 f_b f_l hiddent" %>
|
||||
<% if User.current.logged? %>
|
||||
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
|
||||
<%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
|
||||
|
||||
<% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
|
||||
<span id="is_public_<%= file.id %>">
|
||||
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
|
||||
</span>
|
||||
<% else %>
|
||||
<!-- <#%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> -->
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to("选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="">
|
||||
<p class="f_l mb5 c_grey02">文件大小:<%= number_to_human_size(file.filesize) %></p>
|
||||
<%= link_to( l(:button_delete), attachment_path(file),
|
||||
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%>
|
||||
<p class="f_r c_grey02" ><%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %> | 引用<%= file.quotes.nil? ? 0:file.quotes %> </p>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="tag_h">
|
||||
<%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
|
||||
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div><!---re_con_box end-->
|
||||
<% else %>
|
||||
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
|
||||
<% end %>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue