forked from saurabh/personal-journal
fixes in journal paper for frontend
This commit is contained in:
parent
5ac4d065e2
commit
78b32248cf
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,4 @@
|
|||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
|
@ -32,7 +32,6 @@ class Admin::JournalPapersController < OrbitMemberController
|
|||
end
|
||||
|
||||
def edit
|
||||
@journal_paper = JournalPaper.find(params[:id])
|
||||
@members_data = JournalPaper.member_data rescue nil
|
||||
end
|
||||
|
||||
|
@ -50,17 +49,16 @@ class Admin::JournalPapersController < OrbitMemberController
|
|||
end
|
||||
|
||||
def update
|
||||
@writing_journal = JournalPaper.find(params[:id])
|
||||
@journal_paper_authors = @writing_journal.journal_paper_authors
|
||||
@journal_paper_authors = @journal_paper.journal_paper_authors
|
||||
|
||||
respond_to do |format|
|
||||
if @writing_journal.update_attributes(journal_paper_attributes)
|
||||
if @journal_paper.update_attributes(journal_paper_attributes)
|
||||
format.html { redirect_to admin_journal_papers_path }
|
||||
# format.js { render 'toggle_enable' }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.xml { render :xml => @writing_journal.errors, :status => :unprocessable_entity }
|
||||
format.xml { render :xml => @journal_paper.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -168,7 +166,15 @@ class Admin::JournalPapersController < OrbitMemberController
|
|||
private
|
||||
|
||||
def set_journal_paper
|
||||
@journal_paper = JournalPaper.find(params[:id])
|
||||
path = request.path.split('/')
|
||||
if path.last.include? '-'
|
||||
uid = path[-1].split("-").last
|
||||
uid = uid.split("?").first
|
||||
else
|
||||
uid = path[-2].split("-").last
|
||||
uid = uid.split("?").first
|
||||
end
|
||||
@journal_paper = JournalPaper.find_by(uid: uid)
|
||||
end
|
||||
|
||||
def journal_paper_attributes
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
module JournalPapersHelper
|
||||
end
|
|
@ -4,8 +4,10 @@ class JournalPaper
|
|||
include Mongoid::Attributes::Dynamic
|
||||
|
||||
include OrbitModel::Status
|
||||
include MemberHelper
|
||||
include Slug
|
||||
|
||||
field :paper_title, type: String, localize: true
|
||||
field :paper_title, as: :slug_title, type: String, localize: true
|
||||
field :journal_title, type: String, localize: true
|
||||
field :year, type: String
|
||||
field :language, type: String
|
||||
|
@ -89,6 +91,16 @@ class JournalPaper
|
|||
end
|
||||
end
|
||||
|
||||
def values_for_view
|
||||
attribute_values = self.attributes.select{|k,v| v if k.in?(["year","language","isbn","vol_no","issue_no","form_to_start","form_to_end","total_pages","keywords","abstract","publication_date","url","note"])}
|
||||
localized_fields = {"paper_title" => self.attributes["paper_title"][I18n.locale], "journal_title" => self.attributes["journal_title"][I18n.locale]}
|
||||
authors = {"authors" => self.authors}
|
||||
files = Hash.new
|
||||
self.journal_paper_files.each do |f| files = {"file_link" => url_to_file(f.journal_file.url, f.title)} end
|
||||
values = [attribute_values, localized_fields, authors,files]
|
||||
values.inject(&:merge)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def add_http
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
<% end -%>
|
||||
<td><%= writing_journal.year %></td>
|
||||
<td>
|
||||
<%= link_to writing_journal.create_link, admin_journal_paper_path(writing_journal) %>
|
||||
<%= link_to writing_journal.create_link %>
|
||||
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills hide">
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
|
||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||
namespace :admin do
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
require 'test_helper'
|
||||
|
||||
class JournalPapersControllerTest < ActionController::TestCase
|
||||
test "should get show" do
|
||||
get :show
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class JournalPapersHelperTest < ActionView::TestCase
|
||||
end
|
Loading…
Reference in New Issue