1、部分页面根据apptoken参数自动登录功能添加token是否过期判断。2、版本管理发布新版本信息功能添加

This commit is contained in:
z9hang 2015-03-10 14:41:36 +08:00
parent 7e34ce48bf
commit 803f4a3eaf
5 changed files with 29 additions and 2 deletions

View File

@ -337,7 +337,28 @@ class AdminController < ApplicationController
end
def create_version
@versions = PhoneAppVersion.reorder('created_at desc')
@new_version = PhoneAppVersion.new
@new_version.version = params[:version]
@new_version.description = params[:description]
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

View File

@ -181,6 +181,9 @@ class ApplicationController < ActionController::Base
#从手机端传来apptoken则将当前登陆用户变为对应的用户
if params[:apptoken]
token = ApiKey.where(access_token: params[:apptoken]).first
if token.expired?
return
end
if token && !token.expired?
@current_user = User.find(token.user_id)
end

View File

@ -1,3 +1,5 @@
class PhoneAppVersion < ActiveRecord::Base
attr_accessible :description, :version
validates_presence_of :description, :version
validates_uniqueness_of :version
end

View File

@ -1,7 +1,7 @@
<h3><%= l(:label_mobile_version) %></h3>
<a href="javascript:void(0)" onclick="$('#new_version').slideToggle(400); ">发布新版本</a>
<div>
<%= form_tag(:controller => 'admin', :action => 'create_version') do %>
<%= form_tag({:controller => 'admin', :action => 'create_version'},{:id => 'new_version',:style=>'display:none'}) do %>
<p style="margin-left:60px;padding-right: 20px;">
<label for='version'><%= l(:label_version_number) %>:</label>
<%= text_field_tag 'version', params[:version],:value => @new_version.version, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>

View File

@ -1979,6 +1979,7 @@ zh:
label_forum_update_succ: 贴吧更新成功
label_forum_update_fail: 贴吧更新失败
label_first_page_create_fail: 首页定制失败
label_version_create_fail: 版本发布失败
label_forum_edit: 编辑讨论区
label_memo_create: 发布
label_memo_new: 新建帖子