spina-admin-journal 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spina/admin/journal/articles_controller.rb +1 -1
- data/app/controllers/spina/admin/journal/journals_controller.rb +1 -1
- data/app/controllers/spina/admin/journal/licences_controller.rb +95 -0
- data/app/models/spina/admin/journal/article.rb +3 -0
- data/app/models/spina/admin/journal/licence.rb +32 -0
- data/app/views/layouts/spina/admin/journal/licences.html.haml +10 -0
- data/app/views/spina/admin/hooks/journal/_primary_navigation.html.haml +4 -2
- data/app/views/spina/admin/journal/articles/_form_details.html.haml +5 -0
- data/app/views/spina/admin/journal/licences/_form.html.haml +43 -0
- data/app/views/spina/admin/journal/licences/_licence.html.haml +11 -0
- data/app/views/spina/admin/journal/licences/edit.html.haml +1 -0
- data/app/views/spina/admin/journal/licences/index.html.haml +17 -0
- data/app/views/spina/admin/journal/licences/new.html.haml +1 -0
- data/config/locales/en.yml +20 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20210618090155_create_spina_admin_journal_licences.rb +13 -0
- data/db/migrate/20210618094533_add_licence_to_spina_admin_journal_articles.rb +8 -0
- data/lib/spina/admin/journal/version.rb +1 -1
- metadata +13 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c43ca7425af717514efb0bc6a142651eae11fd79446019ab19b87bb8c952f497
|
4
|
+
data.tar.gz: 3af013de932268d05fb32013c7d1f09a89166eedd43276ce73c1756819cdea75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d792437f01a6474b290daa7deaea9232eb78892a77e08c877abbab9ce97221785c653eca15062b2656a70e155b74ad3ed77aae3e2a3260306c153bfb9c4401fc
|
7
|
+
data.tar.gz: 1ef7f100bd6d37727916951f588d4fcad17d4c896e3fab8c136f2ac663b0290afb3293adc3c6c1cb2d1e99f463363a4c352879a09d53df624e31403d1120a111
|
@@ -19,7 +19,7 @@ module Spina
|
|
19
19
|
CONTENT_PARAMS = Spina.config.locales.inject({}) do |params, locale|
|
20
20
|
params.merge("#{locale}_content_attributes": [*PARTS_PARAMS])
|
21
21
|
end
|
22
|
-
PARAMS = [:issue_id, :title, :url, :doi, :status, { affiliation_ids: [], **CONTENT_PARAMS }].freeze
|
22
|
+
PARAMS = [:issue_id, :licence_id, :title, :url, :doi, :status, { affiliation_ids: [], **CONTENT_PARAMS }].freeze
|
23
23
|
PARTS = %w[abstract attachment].freeze
|
24
24
|
|
25
25
|
before_action :set_breadcrumb
|
@@ -21,7 +21,7 @@ module Spina
|
|
21
21
|
params.merge("#{locale}_content_attributes": [*PARTS_PARAMS])
|
22
22
|
end
|
23
23
|
PARAMS = [:name, { **CONTENT_PARAMS }].freeze
|
24
|
-
PARTS = %w[logo description].freeze
|
24
|
+
PARTS = %w[journal_abbreviation logo description documents].freeze
|
25
25
|
|
26
26
|
before_action :set_journal
|
27
27
|
before_action :set_parts_attributes
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spina
|
4
|
+
module Admin
|
5
|
+
module Journal
|
6
|
+
# Controller for {Licence} records.
|
7
|
+
class LicencesController < ApplicationController
|
8
|
+
PARTS_PARAMS = [
|
9
|
+
:name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id,
|
10
|
+
{ images_attributes: %i[filename signed_blob_id image_id alt],
|
11
|
+
content_attributes: [
|
12
|
+
:name, :title,
|
13
|
+
{ parts_attributes: [
|
14
|
+
:name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id,
|
15
|
+
{ images_attributes: %i[filename signed_blob_id image_id alt] }
|
16
|
+
] }
|
17
|
+
] }
|
18
|
+
].freeze
|
19
|
+
CONTENT_PARAMS = Spina.config.locales.inject({}) do |params, locale|
|
20
|
+
params.merge("#{locale}_content_attributes": [*PARTS_PARAMS])
|
21
|
+
end
|
22
|
+
PARAMS = [:name, :abbreviated_name, { **CONTENT_PARAMS }].freeze
|
23
|
+
PARTS = %w[text url logo].freeze
|
24
|
+
|
25
|
+
before_action :set_breadcrumb
|
26
|
+
before_action :set_licence, only: %i[edit update destroy]
|
27
|
+
before_action :set_parts_attributes, only: %i[new edit]
|
28
|
+
before_action :build_parts, only: %i[edit]
|
29
|
+
|
30
|
+
def index
|
31
|
+
@licences = Licence.sorted
|
32
|
+
end
|
33
|
+
|
34
|
+
def new
|
35
|
+
@licence = Licence.new
|
36
|
+
build_parts
|
37
|
+
add_breadcrumb t('.new')
|
38
|
+
end
|
39
|
+
|
40
|
+
def edit; end
|
41
|
+
|
42
|
+
def create
|
43
|
+
@licence = Licence.new(licence_params)
|
44
|
+
if @licence.save
|
45
|
+
redirect_to admin_journal_licences_path, success: t('.saved')
|
46
|
+
else
|
47
|
+
render :new
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def update
|
52
|
+
if @licence.update(licence_params)
|
53
|
+
redirect_to admin_journal_licences_path, success: t('.saved')
|
54
|
+
else
|
55
|
+
render :edit
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def destroy
|
60
|
+
@licence.destroy
|
61
|
+
respond_to do |format|
|
62
|
+
format.html do
|
63
|
+
redirect_to admin_journal_licences_path, success: t('.deleted')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def licence_params
|
71
|
+
params.require(:admin_journal_licence).permit(PARAMS)
|
72
|
+
end
|
73
|
+
|
74
|
+
def set_breadcrumb
|
75
|
+
add_breadcrumb Licence.model_name.human(count: :many), admin_journal_licences_path
|
76
|
+
end
|
77
|
+
|
78
|
+
def set_licence
|
79
|
+
@licence = Licence.find(params[:id])
|
80
|
+
add_breadcrumb @licence.name
|
81
|
+
end
|
82
|
+
|
83
|
+
def set_parts_attributes
|
84
|
+
@parts_attributes = current_theme.parts.select { |part| PARTS.include? part[:name] }
|
85
|
+
end
|
86
|
+
|
87
|
+
def build_parts
|
88
|
+
return unless @parts_attributes.is_a? Array
|
89
|
+
|
90
|
+
@parts = @parts_attributes.collect { |part_attributes| @licence.part(part_attributes) }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -34,6 +34,9 @@ module Spina
|
|
34
34
|
# @!attribute [rw] issue
|
35
35
|
# @return [Issue] The issue that contains this article.
|
36
36
|
belongs_to :issue
|
37
|
+
# @!attribute [rw] licence
|
38
|
+
# @return [Licence] the licence under which the article is released
|
39
|
+
belongs_to :licence, optional: true
|
37
40
|
|
38
41
|
# @!attribute [rw] authorships
|
39
42
|
has_many :authorships, dependent: :destroy
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spina
|
4
|
+
module Admin
|
5
|
+
module Journal
|
6
|
+
# A record to hold information about copyright licences.
|
7
|
+
#
|
8
|
+
# Associated with individual articles.
|
9
|
+
#
|
10
|
+
# === Validators
|
11
|
+
# Presence:: {#name}
|
12
|
+
class Licence < ApplicationRecord
|
13
|
+
include AttrJson::Record
|
14
|
+
include AttrJson::NestedAttributes
|
15
|
+
include Spina::Partable
|
16
|
+
include Spina::TranslatedContent
|
17
|
+
|
18
|
+
# @!attribute [rw] name
|
19
|
+
# @return [String] the name of the licence
|
20
|
+
# @!attribute [rw] abbreviated_name
|
21
|
+
# @return [String] an optional abbreviated form of the licence name
|
22
|
+
# @!attribute [rw] articles
|
23
|
+
# @return [ActiveRecord::Relation] articles which use this licence
|
24
|
+
has_many :articles, dependent: :nullify
|
25
|
+
|
26
|
+
validates :name, presence: true
|
27
|
+
|
28
|
+
scope :sorted, -> { order(name: :asc) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
%li{ class: ('active' if %w[articles issues volumes].include? controller_name) }
|
2
2
|
= link_to admin_journal_volumes_path do
|
3
3
|
= icon 'pages'
|
4
|
-
= ::Spina::Admin::Journal::Journal.instance.name
|
4
|
+
= ::Spina::Admin::Journal::Journal.instance.has_content?(:journal_abbreviation) ? ::Spina::Admin::Journal::Journal.instance.content(:journal_abbreviation) : ::Spina::Admin::Journal::Journal.instance.name
|
5
5
|
= icon 'caret-right'
|
6
6
|
|
7
7
|
%ul
|
@@ -12,7 +12,7 @@
|
|
12
12
|
%li{ class: ('active' if %w[articles].include? controller_name) }
|
13
13
|
= link_to ::Spina::Admin::Journal::Article.model_name.human(count: :many), admin_journal_articles_path
|
14
14
|
|
15
|
-
%li{ class: ('active' if %w[journals authors institutions].include? controller_name) }
|
15
|
+
%li{ class: ('active' if %w[journals authors institutions licences].include? controller_name) }
|
16
16
|
= link_to edit_admin_journal_journal_path(::Spina::Admin::Journal::Journal.instance.id) do
|
17
17
|
= icon 'dots'
|
18
18
|
= t 'spina.admin.journal.navigation_title'
|
@@ -25,3 +25,5 @@
|
|
25
25
|
= link_to ::Spina::Admin::Journal::Author.model_name.human(count: :many), admin_journal_authors_path
|
26
26
|
%li{ class: ('active' if %w[institutions].include? controller_name) }
|
27
27
|
= link_to ::Spina::Admin::Journal::Institution.model_name.human(count: :many), admin_journal_institutions_path
|
28
|
+
%li{ class: ('active' if %w[licences].include? controller_name) }
|
29
|
+
= link_to ::Spina::Admin::Journal::Licence.model_name.human(count: :many), admin_journal_licences_path
|
@@ -20,6 +20,11 @@
|
|
20
20
|
= Spina::Admin::Journal::Article.human_attribute_name :status
|
21
21
|
.page-form-content
|
22
22
|
= f.select :status, Spina::Admin::Journal::Article.statuses.keys.map { |key| [key.humanize, key] }
|
23
|
+
.page-form-group
|
24
|
+
.page-form-label
|
25
|
+
= Spina::Admin::Journal::Article.human_attribute_name :licence
|
26
|
+
.page-form-content
|
27
|
+
= f.collection_select :licence_id, Spina::Admin::Journal::Licence.sorted, :id, :name, prompt: true
|
23
28
|
.page-form-group
|
24
29
|
.page-form-label
|
25
30
|
= ::Spina::Admin::Journal::Author.model_name.human count: :many
|
@@ -0,0 +1,43 @@
|
|
1
|
+
- if @licence.errors.any?
|
2
|
+
- content_for :notifications do
|
3
|
+
.notification.notification-danger.animated.fadeInRight
|
4
|
+
= icon 'exclamation'
|
5
|
+
.notification-message
|
6
|
+
= t 'spina.notifications.alert'
|
7
|
+
%small= @licence.errors.full_messages.join('<br />').html_safe
|
8
|
+
= link_to '#', data: { close_notification: true } do
|
9
|
+
= icon 'cross'
|
10
|
+
|
11
|
+
= form_for @licence, html: { autocomplete: 'off' } do |f|
|
12
|
+
%header#header
|
13
|
+
= render partial: 'spina/admin/shared/breadcrumbs'
|
14
|
+
|
15
|
+
#header_actions
|
16
|
+
%button.button.button-primary{ type: 'submit', style: 'margin-right: 0', data: { disable_with: t('spina.pages.saving') } }
|
17
|
+
= icon 'check'
|
18
|
+
= t '.save'
|
19
|
+
|
20
|
+
.button{ style: 'margin-right: 0' }= link_to t('spina.cancel'), admin_journal_licences_path
|
21
|
+
|
22
|
+
.page-form
|
23
|
+
.page-form-group
|
24
|
+
.page-form-label
|
25
|
+
= ::Spina::Admin::Journal::Licence.human_attribute_name :name
|
26
|
+
.page-form-content
|
27
|
+
= f.text_field :name
|
28
|
+
.page-form-group
|
29
|
+
.page-form-label
|
30
|
+
= ::Spina::Admin::Journal::Licence.human_attribute_name :abbreviated_name
|
31
|
+
.page-form-content
|
32
|
+
= f.text_field :abbreviated_name
|
33
|
+
|
34
|
+
= f.fields_for :"#{@locale}_content", @parts do |ff|
|
35
|
+
= ff.hidden_field :type, value: ff.object.class.name
|
36
|
+
= ff.hidden_field :title
|
37
|
+
= ff.hidden_field :name
|
38
|
+
|
39
|
+
.page-form-group.page-part{ data: { name: ff.object.name } }
|
40
|
+
= render "spina/admin/parts/#{parts_partial_namespace(ff.object.class.name)}/form", f: ff
|
41
|
+
|
42
|
+
- unless @licence.new_record?
|
43
|
+
.pull-right= link_to t('spina.permanently_delete'), admin_journal_licence_path(@licence), method: :delete, data: { confirm: t('.delete_confirmation', name: @licence.name) }, class: 'button button-link button-danger'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
%tr{ data: { id: licence.id } }
|
2
|
+
%td
|
3
|
+
= link_to licence.name, edit_admin_journal_licence_path(licence)
|
4
|
+
%td
|
5
|
+
= licence.abbreviated_name
|
6
|
+
%td
|
7
|
+
= licence.articles.count
|
8
|
+
%td.nowrap.align-right
|
9
|
+
= link_to edit_admin_journal_licence_path(licence), class: 'button button-link' do
|
10
|
+
= icon 'pencil-outline'
|
11
|
+
= t '.edit'
|
@@ -0,0 +1 @@
|
|
1
|
+
= render 'form'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
- content_for(:header_actions) do
|
2
|
+
= link_to new_admin_journal_licence_path, class: 'button button-primary' do
|
3
|
+
= icon 'plus'
|
4
|
+
= t '.new'
|
5
|
+
|
6
|
+
.well
|
7
|
+
.table-container
|
8
|
+
%table.table
|
9
|
+
%thead
|
10
|
+
%tr
|
11
|
+
%th= ::Spina::Admin::Journal::Licence.human_attribute_name :name
|
12
|
+
%th= ::Spina::Admin::Journal::Licence.human_attribute_name :abbreviated_name
|
13
|
+
%th= t '.num_articles'
|
14
|
+
%th
|
15
|
+
|
16
|
+
%tbody
|
17
|
+
= render @licences.any? ? @licences : 'empty_list', message: t('.empty')
|
@@ -0,0 +1 @@
|
|
1
|
+
= render 'form'
|
data/config/locales/en.yml
CHANGED
@@ -134,6 +134,20 @@ en:
|
|
134
134
|
delete_confirmation:
|
135
135
|
"Are you sure you want to delete the institution <strong>%{name}</strong>?
|
136
136
|
This action is irreversible, and will delete all associated affiliations. Authors will not be deleted."
|
137
|
+
licences:
|
138
|
+
new:
|
139
|
+
new: New licence
|
140
|
+
create:
|
141
|
+
saved: Licence saved.
|
142
|
+
update:
|
143
|
+
saved: Licence saved.
|
144
|
+
destroy:
|
145
|
+
deleted: Licence deleted.
|
146
|
+
form:
|
147
|
+
save: Save licence
|
148
|
+
delete_confirmation:
|
149
|
+
"Are you sure you want to delete the licence <strong>%{name}</strong>?"
|
150
|
+
|
137
151
|
activerecord:
|
138
152
|
models:
|
139
153
|
spina/admin/journal/journal:
|
@@ -160,6 +174,9 @@ en:
|
|
160
174
|
spina/admin/journal/institution:
|
161
175
|
one: Institution
|
162
176
|
other: Institutions
|
177
|
+
spina/admin/journal/licence:
|
178
|
+
one: Licence
|
179
|
+
other: Licences
|
163
180
|
attributes:
|
164
181
|
spina/admin/journal/journal:
|
165
182
|
name: Name
|
@@ -180,6 +197,9 @@ en:
|
|
180
197
|
spina/admin/journal/author:
|
181
198
|
spina/admin/journal/institution:
|
182
199
|
name: Institution Name
|
200
|
+
spina/admin/journal/licence:
|
201
|
+
name: Licence Name
|
202
|
+
abbreviated_name: Short Name
|
183
203
|
|
184
204
|
date:
|
185
205
|
formats:
|
data/config/routes.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateSpinaAdminJournalLicences < ActiveRecord::Migration[6.1] # :nodoc:
|
4
|
+
def change
|
5
|
+
create_table :spina_admin_journal_licences do |t|
|
6
|
+
t.string :name, null: false, default: 'Unnamed Licence'
|
7
|
+
t.string :abbreviated_name, null: false, default: ''
|
8
|
+
t.jsonb :json_attributes
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AddLicenceToSpinaAdminJournalArticles < ActiveRecord::Migration[6.1] # :nodoc:
|
4
|
+
def change
|
5
|
+
add_reference :spina_admin_journal_articles, :licence, null: true,
|
6
|
+
foreign_key: { to_table: :spina_admin_journal_licences }
|
7
|
+
end
|
8
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spina-admin-journal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Louis Van Steene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: babel-transpiler
|
@@ -281,6 +281,7 @@ files:
|
|
281
281
|
- app/controllers/spina/admin/journal/institutions_controller.rb
|
282
282
|
- app/controllers/spina/admin/journal/issues_controller.rb
|
283
283
|
- app/controllers/spina/admin/journal/journals_controller.rb
|
284
|
+
- app/controllers/spina/admin/journal/licences_controller.rb
|
284
285
|
- app/controllers/spina/admin/journal/volumes_controller.rb
|
285
286
|
- app/models/spina/admin/journal.rb
|
286
287
|
- app/models/spina/admin/journal/affiliation.rb
|
@@ -290,6 +291,7 @@ files:
|
|
290
291
|
- app/models/spina/admin/journal/institution.rb
|
291
292
|
- app/models/spina/admin/journal/issue.rb
|
292
293
|
- app/models/spina/admin/journal/journal.rb
|
294
|
+
- app/models/spina/admin/journal/licence.rb
|
293
295
|
- app/models/spina/admin/journal/volume.rb
|
294
296
|
- app/validators/spina/admin/journal/uri_validator.rb
|
295
297
|
- app/views/layouts/spina/admin/journal/articles.html.haml
|
@@ -297,6 +299,7 @@ files:
|
|
297
299
|
- app/views/layouts/spina/admin/journal/institutions.html.haml
|
298
300
|
- app/views/layouts/spina/admin/journal/issues.html.haml
|
299
301
|
- app/views/layouts/spina/admin/journal/journals.html.haml
|
302
|
+
- app/views/layouts/spina/admin/journal/licences.html.haml
|
300
303
|
- app/views/layouts/spina/admin/journal/volumes.html.haml
|
301
304
|
- app/views/spina/admin/hooks/journal/_head.html.haml
|
302
305
|
- app/views/spina/admin/hooks/journal/_primary_navigation.html.haml
|
@@ -337,6 +340,11 @@ files:
|
|
337
340
|
- app/views/spina/admin/journal/journals/edit.html.haml
|
338
341
|
- app/views/spina/admin/journal/journals/index.html.haml
|
339
342
|
- app/views/spina/admin/journal/journals/new.html.haml
|
343
|
+
- app/views/spina/admin/journal/licences/_form.html.haml
|
344
|
+
- app/views/spina/admin/journal/licences/_licence.html.haml
|
345
|
+
- app/views/spina/admin/journal/licences/edit.html.haml
|
346
|
+
- app/views/spina/admin/journal/licences/index.html.haml
|
347
|
+
- app/views/spina/admin/journal/licences/new.html.haml
|
340
348
|
- app/views/spina/admin/journal/volumes/_form.html.haml
|
341
349
|
- app/views/spina/admin/journal/volumes/_form_details.html.haml
|
342
350
|
- app/views/spina/admin/journal/volumes/_form_issues.html.haml
|
@@ -360,6 +368,8 @@ files:
|
|
360
368
|
- db/migrate/20210424123555_add_json_attributes_to_spina_admin_journal_articles.rb
|
361
369
|
- db/migrate/20210512122931_add_position_to_spina_admin_journal_authorships.rb
|
362
370
|
- db/migrate/20210521121318_add_status_to_spina_admin_journal_articles.rb
|
371
|
+
- db/migrate/20210618090155_create_spina_admin_journal_licences.rb
|
372
|
+
- db/migrate/20210618094533_add_licence_to_spina_admin_journal_articles.rb
|
363
373
|
- lib/spina/admin/journal.rb
|
364
374
|
- lib/spina/admin/journal/engine.rb
|
365
375
|
- lib/spina/admin/journal/version.rb
|
@@ -384,7 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
384
394
|
- !ruby/object:Gem::Version
|
385
395
|
version: '0'
|
386
396
|
requirements: []
|
387
|
-
rubygems_version: 3.1.
|
397
|
+
rubygems_version: 3.1.6
|
388
398
|
signing_key:
|
389
399
|
specification_version: 4
|
390
400
|
summary: Academic journal plugin for Spina.
|