Skip to content

Commit

Permalink
Merge branch 'release/v0.12.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
ja573 committed Apr 26, 2024
2 parents f4e848a + 1fd3ee4 commit a494e74
Show file tree
Hide file tree
Showing 49 changed files with 777 additions and 176 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [[0.12.3]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.3) - 2024-04-26
### Added
- [583](https://github.com/thoth-pub/thoth/issues/583) - Add new field, Permanently Withdrawn Date, to Work for Out-of-print or Withdrawn from Sale Works.

### Fixed
- [597](https://github.com/thoth-pub/thoth/issues/597) - Graphiql not working in chrome and safari

### Changed
- [218](https://github.com/thoth-pub/thoth/issues/218) - Make series ISSN optional

## [[0.12.2]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.2) - 2024-04-16
### Added
- [581](https://github.com/thoth-pub/thoth/issues/581) - Add crossmark policy DOI to imprint record
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thoth"
version = "0.12.2"
version = "0.12.3"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -16,11 +16,11 @@ maintenance = { status = "actively-developed" }
members = ["thoth-api", "thoth-api-server", "thoth-app", "thoth-app-server", "thoth-client", "thoth-errors", "thoth-export-server"]

[dependencies]
thoth-api = { version = "0.12.2", path = "thoth-api", features = ["backend"] }
thoth-api-server = { version = "0.12.2", path = "thoth-api-server" }
thoth-app-server = { version = "0.12.2", path = "thoth-app-server" }
thoth-errors = { version = "0.12.2", path = "thoth-errors" }
thoth-export-server = { version = "0.12.2", path = "thoth-export-server" }
thoth-api = { version = "0.12.3", path = "thoth-api", features = ["backend"] }
thoth-api-server = { version = "0.12.3", path = "thoth-api-server" }
thoth-app-server = { version = "0.12.3", path = "thoth-app-server" }
thoth-errors = { version = "0.12.3", path = "thoth-errors" }
thoth-export-server = { version = "0.12.3", path = "thoth-export-server" }
clap = { version = "4.4.7", features = ["cargo", "env"] }
dialoguer = { version = "0.11.0", features = ["password"] }
dotenv = "0.15.0"
Expand Down
6 changes: 3 additions & 3 deletions thoth-api-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thoth-api-server"
version = "0.12.2"
version = "0.12.3"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -9,8 +9,8 @@ repository = "https://github.com/thoth-pub/thoth"
readme = "README.md"

[dependencies]
thoth-api = { version = "0.12.2", path = "../thoth-api", features = ["backend"] }
thoth-errors = { version = "0.12.2", path = "../thoth-errors" }
thoth-api = { version = "0.12.3", path = "../thoth-api", features = ["backend"] }
thoth-errors = { version = "0.12.3", path = "../thoth-errors" }
actix-web = "4.5.1"
actix-cors = "0.7.0"
actix-identity = "0.7.1"
Expand Down
4 changes: 0 additions & 4 deletions thoth-api-server/src/graphiql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ pub fn graphiql_source(graphql_endpoint_url: &str) -> String {
const fetcher = GraphiQL.createFetcher({{
url: '{graphql_endpoint_url}',
method: 'post',
headers: {{
'Accept': 'application/json',
'Content-Type': 'application/json',
}},
}});
const explorerPlugin = GraphiQLPluginExplorer.explorerPlugin();
root.render(
Expand Down
4 changes: 2 additions & 2 deletions thoth-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thoth-api"
version = "0.12.2"
version = "0.12.3"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -16,7 +16,7 @@ maintenance = { status = "actively-developed" }
backend = ["diesel", "diesel-derive-enum", "diesel_migrations", "futures", "actix-web", "jsonwebtoken"]

[dependencies]
thoth-errors = { version = "0.12.2", path = "../thoth-errors" }
thoth-errors = { version = "0.12.3", path = "../thoth-errors" }
actix-web = { version = "4.5.1", optional = true }
argon2rs = "0.2.5"
isbn2 = "0.4.0"
Expand Down
12 changes: 12 additions & 0 deletions thoth-api/migrations/v0.12.3/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ALTER TABLE series
ALTER COLUMN issn_print SET NOT NULL;

ALTER TABLE series
ALTER COLUMN issn_digital SET NOT NULL;

ALTER TABLE work
DROP CONSTRAINT work_active_withdrawn_date_check,
DROP CONSTRAINT work_inactive_no_withdrawn_date_check,
DROP CONSTRAINT work_withdrawn_date_after_publication_date_check,
DROP COLUMN withdrawn_date;

25 changes: 25 additions & 0 deletions thoth-api/migrations/v0.12.3/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ALTER TABLE series
ALTER COLUMN issn_print DROP NOT NULL;

ALTER TABLE series
ALTER COLUMN issn_digital DROP NOT NULL;

ALTER TABLE work
ADD COLUMN withdrawn_date DATE;

UPDATE work
SET withdrawn_date = updated_at
WHERE (work_status = 'withdrawn-from-sale'
OR work_status = 'out-of-print');

ALTER TABLE work
ADD CONSTRAINT work_active_withdrawn_date_check CHECK
((work_status = 'withdrawn-from-sale' OR work_status = 'out-of-print')
OR (work_status NOT IN ('withdrawn-from-sale', 'out-of-print') AND withdrawn_date IS NULL)),

ADD CONSTRAINT work_inactive_no_withdrawn_date_check CHECK
(((work_status = 'withdrawn-from-sale' OR work_status = 'out-of-print') AND withdrawn_date IS NOT NULL)
OR (work_status NOT IN ('withdrawn-from-sale', 'out-of-print'))),

ADD CONSTRAINT work_withdrawn_date_after_publication_date_check CHECK
(withdrawn_date IS NULL OR (publication_date < withdrawn_date));
23 changes: 18 additions & 5 deletions thoth-api/src/graphql/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::model::publisher::*;
use crate::model::reference::*;
use crate::model::series::*;
use crate::model::subject::*;
use crate::model::work::crud::WorkValidation;
use crate::model::work::*;
use crate::model::work_relation::*;
use crate::model::Convert;
Expand Down Expand Up @@ -1516,6 +1517,8 @@ impl MutationRoot {
.account_access
.can_edit(publisher_id_from_imprint_id(&context.db, data.imprint_id)?)?;

data.validate()?;

Work::create(&context.db, &data).map_err(|e| e.into())
}

Expand Down Expand Up @@ -1705,17 +1708,20 @@ impl MutationRoot {
work.can_be_chapter(&context.db)?;
}

data.validate()?;
let account_id = context.token.jwt.as_ref().unwrap().account_id(&context.db);
// update the work and, if it succeeds, synchronise its children statuses and pub. date
match work.update(&context.db, &data, &account_id) {
Ok(w) => {
// update chapters if their pub. data or work_status doesn't match the parent's
// update chapters if their pub. data, withdrawn_date or work_status doesn't match the parent's
for child in work.children(&context.db)? {
if child.publication_date != w.publication_date
|| child.work_status != w.work_status
|| child.withdrawn_date != w.withdrawn_date
{
let mut data: PatchWork = child.clone().into();
data.publication_date = w.publication_date;
data.withdrawn_date = w.withdrawn_date;
data.work_status = w.work_status.clone();
child.update(&context.db, &data, &account_id)?;
}
Expand Down Expand Up @@ -2279,6 +2285,13 @@ impl Work {
self.publication_date
}

#[graphql(
description = "Date a work was withdrawn from publication. Only applies to out of print and withdrawn from sale works."
)]
pub fn withdrawn_date(&self) -> Option<NaiveDate> {
self.withdrawn_date
}

pub fn place(&self) -> Option<&String> {
self.place.as_ref()
}
Expand Down Expand Up @@ -3321,12 +3334,12 @@ impl Series {
&self.series_name
}

pub fn issn_print(&self) -> &String {
&self.issn_print
pub fn issn_print(&self) -> Option<&String> {
self.issn_print.as_ref()
}

pub fn issn_digital(&self) -> &String {
&self.issn_digital
pub fn issn_digital(&self) -> Option<&String> {
self.issn_digital.as_ref()
}

#[graphql(description = "URL of the series' landing page")]
Expand Down
72 changes: 59 additions & 13 deletions thoth-api/src/model/series/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ pub struct Series {
pub series_id: Uuid,
pub series_type: SeriesType,
pub series_name: String,
pub issn_print: String,
pub issn_digital: String,
pub issn_print: Option<String>,
pub issn_digital: Option<String>,
pub series_url: Option<String>,
pub imprint_id: Uuid,
pub created_at: Timestamp,
Expand All @@ -77,8 +77,8 @@ pub struct SeriesWithImprint {
pub series_id: Uuid,
pub series_type: SeriesType,
pub series_name: String,
pub issn_print: String,
pub issn_digital: String,
pub issn_print: Option<String>,
pub issn_digital: Option<String>,
pub series_url: Option<String>,
pub series_description: Option<String>,
pub series_cfp_url: Option<String>,
Expand All @@ -94,8 +94,8 @@ pub struct SeriesWithImprint {
pub struct NewSeries {
pub series_type: SeriesType,
pub series_name: String,
pub issn_print: String,
pub issn_digital: String,
pub issn_print: Option<String>,
pub issn_digital: Option<String>,
pub series_url: Option<String>,
pub series_description: Option<String>,
pub series_cfp_url: Option<String>,
Expand All @@ -111,8 +111,8 @@ pub struct PatchSeries {
pub series_id: Uuid,
pub series_type: SeriesType,
pub series_name: String,
pub issn_print: String,
pub issn_digital: String,
pub issn_print: Option<String>,
pub issn_digital: Option<String>,
pub series_url: Option<String>,
pub series_description: Option<String>,
pub series_cfp_url: Option<String>,
Expand Down Expand Up @@ -148,11 +148,21 @@ pub struct SeriesOrderBy {

impl fmt::Display for SeriesWithImprint {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} ({}, {})",
self.series_name, self.issn_print, self.issn_digital
)
write!(f, "{}", self.series_name)?;

let issns: Vec<String> = vec![
self.issn_print.as_ref().cloned(),
self.issn_digital.as_ref().cloned(),
]
.into_iter()
.flatten()
.collect();

if !issns.is_empty() {
write!(f, " ({})", issns.join(", "))?;
}

Ok(())
}
}

Expand Down Expand Up @@ -252,5 +262,41 @@ fn test_seriesfield_fromstr() {
assert!(SeriesField::from_str("Issues").is_err());
}

#[test]
fn test_display_with_issns() {
let series = SeriesWithImprint {
series_name: String::from("Test Series"),
issn_print: Some(String::from("1234-5678")),
issn_digital: Some(String::from("8765-4321")),
..Default::default()
};

let formatted = format!("{}", series);
assert_eq!(formatted, "Test Series (1234-5678, 8765-4321)");
}

#[test]
fn test_display_with_single_issn() {
let series = SeriesWithImprint {
series_name: String::from("Test Series"),
issn_print: Some(String::from("1234-5678")),
..Default::default()
};

let formatted = format!("{}", series);
assert_eq!(formatted, "Test Series (1234-5678)");
}

#[test]
fn test_display_without_issns() {
let series = SeriesWithImprint {
series_name: String::from("Test Series"),
..Default::default()
};

let formatted = format!("{}", series);
assert_eq!(formatted, "Test Series");
}

#[cfg(feature = "backend")]
pub mod crud;
Loading

0 comments on commit a494e74

Please sign in to comment.