Update sort.
This commit is contained in:
parent
9da8f60a6a
commit
658addea48
|
@ -10,7 +10,7 @@ class Admin::ActivitiesController < OrbitMemberController
|
||||||
before_action :allow_admin_only, :only => [:index, :setting]
|
before_action :allow_admin_only, :only => [:index, :setting]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@activities = Activity.order_by(:year => 'desc').page(params[:page]).per(10)
|
@activities = Activity.sort_year_date.page(params[:page]).per(10)
|
||||||
#respond_to do |format|
|
#respond_to do |format|
|
||||||
#format.html
|
#format.html
|
||||||
#format.xml { render :xml => @activities }
|
#format.xml { render :xml => @activities }
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
class PersonalActivitiesController < ApplicationController
|
class PersonalActivitiesController < ApplicationController
|
||||||
def index
|
def index
|
||||||
activities = Activity.where(:is_hidden => false)
|
activities = Activity.sort_for_frontend
|
||||||
.order_by(:year=>'desc')
|
|
||||||
.page(OrbitHelper.params[:page_no])
|
.page(OrbitHelper.params[:page_no])
|
||||||
.per(OrbitHelper.page_data_count)
|
.per(OrbitHelper.page_data_count)
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,9 @@ class Activity
|
||||||
|
|
||||||
accepts_nested_attributes_for :activity_files, :allow_destroy => true
|
accepts_nested_attributes_for :activity_files, :allow_destroy => true
|
||||||
before_validation :add_http
|
before_validation :add_http
|
||||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :publish_date => "desc") }
|
index({year: -1, :activity_start_date => -1, _id: -1}, { unique: false, background: false })
|
||||||
|
scope :sort_year_date, ->{ order_by(:year => "desc", :activity_start_date => "desc", :id=>"desc") }
|
||||||
|
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :activity_start_date => "desc", :id=>"desc") }
|
||||||
|
|
||||||
def get_plugin_data(fields_to_show)
|
def get_plugin_data(fields_to_show)
|
||||||
plugin_datas = []
|
plugin_datas = []
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
<%
|
<%
|
||||||
#@activities = Activity.where(member_profile_id: current_user.member_profile.id).desc(:year).page(params[:page]).per(10)
|
#@activities = Activity.where(member_profile_id: current_user.member_profile.id).desc(:year).page(params[:page]).per(10)
|
||||||
if has_access?
|
if has_access?
|
||||||
@activities = Activity.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
@activities = Activity.where(member_profile_id: @member.id).sort_year_date.page(params[:page]).per(10)
|
||||||
else
|
else
|
||||||
@activities = Activity.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
@activities = Activity.where(is_hidden: false, member_profile_id: @member.id).sort_year_date.page(params[:page]).per(10)
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@ $( ".selectbox" ).ready(function() {
|
||||||
<td><a href="{{link_to_show}}">{{activity_name}}</a></td>
|
<td><a href="{{link_to_show}}">{{activity_name}}</a></td>
|
||||||
<td>{{activity_organizer}}</td>
|
<td>{{activity_organizer}}</td>
|
||||||
<td>{{activity_area}}</td>
|
<td>{{activity_area}}</td>
|
||||||
<td>{{activity_start_date}}</td>
|
<td date-format="%Y-%m-%d">{{activity_start_date}}</td>
|
||||||
<td>{{activity_end_date}}</td>
|
<td date-format="%Y-%m-%d">{{activity_end_date}}</td>
|
||||||
<td>{{note}}</td>
|
<td>{{note}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in New Issue