spina-admin-journal 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 699af672ff6d7d01b9d16ac482555eaf067ad7368d2a9149cd5e530da9f484aa
4
- data.tar.gz: a4fbf7727835537e5f71df2c35b01d3b848764e6a75e2ffeac993e0852bf214d
3
+ metadata.gz: 9558f4aae0173062e342e21d8bc44566933b1d2f60968a1466eb7612bc28250c
4
+ data.tar.gz: 067acad98f36c578ecb367bb8a7179deebb4d0aaad61ebdf82baefb6887f8668
5
5
  SHA512:
6
- metadata.gz: 2a580ab0bf04617189936fc7ea06b9c08e4941a685474fdfd5a896589de7a797f0db602de90d85d95f0f06849b21da71414fdb4d8952abed3d6cda320bc8b6dc
7
- data.tar.gz: 78454dba6fb8c595ee4d31e894dbc17f2217adad8960de4009fd7c373f30502ea8133e32bb985c17fc7dde9b5fea5cef6ecadd620254519f74b9be604ef2169a
6
+ metadata.gz: f67811ae559061d1cdf6120a043f8c3a926c4744950c6db727cd97a3650e03bc4f6bb041e3d527d555e6eb13f7910d38793cb9682997154c1675ed73c858b3f2
7
+ data.tar.gz: 5a60f2a5637a28a7f7ee5ffe6a7413db3deee3a27160ab839479736d677afa00b88cd1ae052827fd613e459e742858d1ba6356eb6c5d814f1d720820ca547842
@@ -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, { affiliation_ids: [], **CONTENT_PARAMS }].freeze
22
+ PARAMS = [:issue_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
@@ -7,12 +7,13 @@ module Spina
7
7
  #
8
8
  # === Validators
9
9
  # Presence:: {#number}, {#title}
10
- # Uniqueness:: {#number} (scope: issue)
10
+ # Uniqueness:: {#number} (scope: issue) {status}
11
11
  # URI:: {#url}
12
12
  #
13
13
  # === Scopes
14
14
  # sorted_asc:: sorted in order of increasing number
15
15
  # sorted_desc:: sorted highest number first
16
+ # visible:: articles that should be visible to the public
16
17
  #
17
18
  # @see Issue
18
19
  # @see Author
@@ -40,12 +41,23 @@ module Spina
40
41
  # @return [ActiveRecord::Relation] The authors of the article.
41
42
  has_many :affiliations, through: :authorships
42
43
 
44
+ # @!attribute [rw] status
45
+ # @return [Integer] th currnt status of the article
46
+ enum status: { published: 0, draft: 1 }
47
+
43
48
  validates :number, presence: true, uniqueness: { scope: :issue_id }
44
49
  validates :title, presence: true
45
50
  validates :url, 'spina/admin/journal/uri': true
51
+ validates :status, presence: true
46
52
 
53
+ scope :visible, -> { where(status: :published) }
47
54
  scope :sorted_asc, -> { includes(:issue).order('spina_admin_journal_issues.number ASC', number: :asc) }
48
55
  scope :sorted_desc, -> { includes(:issue).order('spina_admin_journal_issues.number DESC', number: :desc) }
56
+
57
+ # Returns true if the article should be visible to end users (i.e. is not a draft).
58
+ def visible?
59
+ published?
60
+ end
49
61
  end
50
62
  end
51
63
  end
@@ -15,6 +15,11 @@
15
15
  = ::Spina::Admin::Journal::Article.human_attribute_name :title
16
16
  .page-form-content
17
17
  = f.text_field :title
18
+ .page-form-group
19
+ .page-form-label
20
+ = Spina::Admin::Journal::Article.human_attribute_name :status
21
+ .page-form-content
22
+ = f.select :status, Spina::Admin::Journal::Article.statuses.keys.map { |key| [key.humanize, key] }
18
23
  .page-form-group
19
24
  .page-form-label
20
25
  = ::Spina::Admin::Journal::Author.model_name.human count: :many
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddStatusToSpinaAdminJournalArticles < ActiveRecord::Migration[6.1] # :nodoc:
4
+ def change
5
+ add_column :spina_admin_journal_articles, :status, :integer, null: false, default: 0
6
+ end
7
+ end
@@ -3,7 +3,7 @@
3
3
  module Spina
4
4
  module Admin
5
5
  module Journal
6
- VERSION = '0.3.0'
6
+ VERSION = '0.4.0'
7
7
  end
8
8
  end
9
9
  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.3.0
4
+ version: 0.4.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-05-12 00:00:00.000000000 Z
11
+ date: 2021-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: babel-transpiler
@@ -359,6 +359,7 @@ files:
359
359
  - db/migrate/20210424123521_add_json_attributes_to_spina_admin_journal_issues.rb
360
360
  - db/migrate/20210424123555_add_json_attributes_to_spina_admin_journal_articles.rb
361
361
  - db/migrate/20210512122931_add_position_to_spina_admin_journal_authorships.rb
362
+ - db/migrate/20210521121318_add_status_to_spina_admin_journal_articles.rb
362
363
  - lib/spina/admin/journal.rb
363
364
  - lib/spina/admin/journal/engine.rb
364
365
  - lib/spina/admin/journal/version.rb