1、完成手机app版本管理,上传客户端功能。2、手机app检查更新接口完成
This commit is contained in:
parent
87f0d73ac0
commit
43e9a9a495
|
@ -3,16 +3,23 @@
|
|||
module Mobile
|
||||
module Apis
|
||||
class Upgrade < Grape::API
|
||||
include ApplicationHelper
|
||||
resource :upgrade do
|
||||
desc "get update info"
|
||||
params do
|
||||
requires :platform, type: String, desc: '平台名,android, ios'
|
||||
end
|
||||
get do
|
||||
@current_version = ::PhoneAppVersion.reorder('created_at desc').first
|
||||
attachment = @current_version.attachments.first
|
||||
if attachment.nil?
|
||||
raise '未发现客户端!'
|
||||
end
|
||||
url = Setting.host_name + "/attachments/download/" + attachment.id.to_s + "/" + attachment.filename
|
||||
{
|
||||
version: '2',
|
||||
url: 'http://u06.shellinfo.cn/trustie/Trustie_Beta1.0.0_201412310917.apk',
|
||||
desc: '更新了什么功能'
|
||||
version: @current_version.version,
|
||||
url: url,
|
||||
desc: @current_version.description
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -341,24 +341,37 @@ class AdminController < ApplicationController
|
|||
@new_version = PhoneAppVersion.new
|
||||
@new_version.version = params[:version]
|
||||
@new_version.description = params[:description]
|
||||
if @new_version.save
|
||||
if params[:attachments][:dummy][:file].nil? || params[:attachments][:dummy][:file] == ""
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to mobile_version_url
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
flash.now[:error] = "#{l :label_version_create_fail}: #{@new_version.errors.full_messages[0]}"
|
||||
flash.now[:error] = "#{l :label_version_create_fail}: #{l(:label_client_need)}"
|
||||
#flash.now[:error] = "#{l :label_first_page_create_fail}: #{@course_page.errors.full_messages[0]}"
|
||||
format.html {
|
||||
render :action => 'mobile_version'
|
||||
}
|
||||
format.api { render_validation_errors(@new_version) }
|
||||
end
|
||||
else
|
||||
@new_version.save_attachments(params[:attachments] || (params[:version] && params[:version][:uploads]))
|
||||
if @new_version.save
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to mobile_version_url
|
||||
}
|
||||
format.api { render_api_ok }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
flash.now[:error] = "#{l :label_version_create_fail}: #{@new_version.errors.full_messages[0]}"
|
||||
#flash.now[:error] = "#{l :label_first_page_create_fail}: #{@course_page.errors.full_messages[0]}"
|
||||
format.html {
|
||||
render :action => 'mobile_version'
|
||||
}
|
||||
format.api { render_validation_errors(@new_version) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -233,6 +233,8 @@ class AttachmentsController < ApplicationController
|
|||
format.html { redirect_to_referer_or softapplications_path(@attachment.container) }
|
||||
elsif !@attachment.container.nil? && @attachment.container.is_a?(Bid)
|
||||
format.html { redirect_to_referer_or respond_path(@attachment.container) }
|
||||
elsif !@attachment.container.nil? && @attachment.container.is_a?(PhoneAppVersion)
|
||||
format.html { redirect_to_referer_or mobile_version_path }
|
||||
else
|
||||
if @project.nil?
|
||||
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
|
||||
|
@ -417,7 +419,7 @@ private
|
|||
@attachment.container.board.course)
|
||||
@course = @attachment.container.board.course
|
||||
else
|
||||
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication'
|
||||
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion'
|
||||
@project = @attachment.project
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,4 +2,5 @@ class PhoneAppVersion < ActiveRecord::Base
|
|||
attr_accessible :description, :version
|
||||
validates_presence_of :description, :version
|
||||
validates_uniqueness_of :version
|
||||
acts_as_attachable
|
||||
end
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
<label for='description'><%= l(:label_version_description)%>:</label>
|
||||
<%= text_field_tag 'description', params[:description],:value => @new_version.description,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||
</p>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<%= render :partial => 'attachments/form', :locals => {:container => @new_version} %>
|
||||
</p>
|
||||
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -33,7 +36,10 @@
|
|||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% if @versions.first.attachments.any?%>
|
||||
<% options = {:author => true, :deletable => true } %>
|
||||
<%= render :partial => 'attachments/links', :locals => {:attachments => @versions.first.attachments, :options => options, :is_float => true} %>
|
||||
<% end %>
|
||||
<br/>
|
||||
|
||||
<div>历史版本:</div>
|
||||
|
|
|
@ -1980,6 +1980,7 @@ zh:
|
|||
label_forum_update_fail: 贴吧更新失败
|
||||
label_first_page_create_fail: 首页定制失败
|
||||
label_version_create_fail: 版本发布失败
|
||||
label_client_need: 需上传客户端
|
||||
label_forum_edit: 编辑讨论区
|
||||
label_memo_create: 发布
|
||||
label_memo_new: 新建帖子
|
||||
|
@ -2382,3 +2383,4 @@ zh:
|
|||
label_recently_updated_message: 最近更新了留言
|
||||
label_recently_updated_courseware: 最近更新了课件
|
||||
label_no_courses: 您没有参与任何课程,请搜索课程、加入课程,或者创建课程吧!
|
||||
|
||||
|
|
Loading…
Reference in New Issue