Skip to content

Commit

Permalink
Merge branch 'release/v0.4.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
ja573 committed Aug 12, 2021
2 parents f5a36e1 + 1eaa74c commit 67491ab
Show file tree
Hide file tree
Showing 31 changed files with 578 additions and 119 deletions.
27 changes: 0 additions & 27 deletions .github/workflows/create_release.yml

This file was deleted.

10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to thoth will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [[0.4.5]](https://github.com/thoth-pub/thoth/releases/tag/v0.4.5) - 2021-08-12
### Added
- [#259](https://github.com/thoth-pub/thoth/issues/259) - Units selection dropdown to Work and NewWork pages, which updates the Width/Height display on change
- [#259](https://github.com/thoth-pub/thoth/issues/259) - Local storage key to retain user's choice of units across all Work/NewWork pages
- [#259](https://github.com/thoth-pub/thoth/issues/259) - Backend function to convert to/from database units (mm): uses 1inch = 25.4mm as conversion factor, rounds mm values to nearest mm, rounds cm values to 1 decimal place, rounds inch values to 2 decimal places and then to nearest sixteenth of an inch
- [#259](https://github.com/thoth-pub/thoth/issues/259) - Constraints on Width/Height fields depending on unit selection: user may only enter whole numbers when in mm, numbers with up to 1 decimal place when in cm, numbers with up to 2 decimal places when in inches

### Changed
- [#259](https://github.com/thoth-pub/thoth/issues/259) - GraphQL and APP queries to specify units when submitting new Width/Height values, and handle conversion if required

## [[0.4.4]](https://github.com/thoth-pub/thoth/releases/tag/v0.4.4) - 2021-08-02
### Fixed
- Read button in catalogue now uses the landing page URL instead of the DOI
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.4.4"
version = "0.4.5"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2018"
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.4.4", path = "thoth-api", features = ["backend"] }
thoth-api-server = { version = "0.4.4", path = "thoth-api-server" }
thoth-app-server = { version = "0.4.4", path = "thoth-app-server" }
thoth-errors = { version = "0.4.4", path = "thoth-errors" }
thoth-export-server = { version = "0.4.4", path = "thoth-export-server" }
thoth-api = { version = "0.4.5", path = "thoth-api", features = ["backend"] }
thoth-api-server = { version = "0.4.5", path = "thoth-api-server" }
thoth-app-server = { version = "0.4.5", path = "thoth-app-server" }
thoth-errors = { version = "0.4.5", path = "thoth-errors" }
thoth-export-server = { version = "0.4.5", path = "thoth-export-server" }
clap = "2.33.3"
dialoguer = "0.7.1"
dotenv = "0.9.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.4.4"
version = "0.4.5"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2018"
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.4.4", path = "../thoth-api", features = ["backend"] }
thoth-errors = { version = "0.4.4", path = "../thoth-errors" }
thoth-api = { version = "0.4.5", path = "../thoth-api", features = ["backend"] }
thoth-errors = { version = "0.4.5", path = "../thoth-errors" }
actix-web = "3.3.2"
actix-cors = "0.5.4"
actix-identity = "0.3.1"
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.4.4"
version = "0.4.5"
authors = ["Javier Arias <[email protected]>", "Ross Higman <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand All @@ -16,7 +16,7 @@ maintenance = { status = "actively-developed" }
backend = ["diesel", "diesel-derive-enum", "diesel_migrations", "futures", "actix-web"]

[dependencies]
thoth-errors = { version = "0.4.4", path = "../thoth-errors" }
thoth-errors = { version = "0.4.5", path = "../thoth-errors" }
actix-web = { version = "3.3.2", optional = true }
argon2rs = "0.2.5"
isbn2 = "0.4.0"
Expand Down
3 changes: 3 additions & 0 deletions thoth-api/migrations/0.4.5/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE work
ALTER COLUMN width TYPE INTEGER,
ALTER COLUMN height TYPE INTEGER;
3 changes: 3 additions & 0 deletions thoth-api/migrations/0.4.5/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE work
ALTER COLUMN width TYPE double precision,
ALTER COLUMN height TYPE double precision;
38 changes: 30 additions & 8 deletions thoth-api/src/graphql/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ use crate::funding::model::*;
use crate::imprint::model::*;
use crate::issue::model::*;
use crate::language::model::*;
use crate::model::Convert;
use crate::model::Crud;
use crate::model::Doi;
use crate::model::Isbn;
use crate::model::LengthUnit;
use crate::model::Orcid;
use crate::model::Timestamp;
use crate::price::model::*;
Expand Down Expand Up @@ -934,13 +936,13 @@ pub struct MutationRoot;

#[juniper::object(Context = Context)]
impl MutationRoot {
fn create_work(context: &Context, data: NewWork) -> FieldResult<Work> {
fn create_work(context: &Context, data: NewWork, units: LengthUnit) -> FieldResult<Work> {
context.token.jwt.as_ref().ok_or(ThothError::Unauthorised)?;
context
.account_access
.can_edit(publisher_id_from_imprint_id(&context.db, data.imprint_id)?)?;

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

fn create_publisher(context: &Context, data: NewPublisher) -> FieldResult<Publisher> {
Expand Down Expand Up @@ -1049,7 +1051,7 @@ impl MutationRoot {
Subject::create(&context.db, &data).map_err(|e| e.into())
}

fn update_work(context: &Context, data: PatchWork) -> FieldResult<Work> {
fn update_work(context: &Context, data: PatchWork, units: LengthUnit) -> FieldResult<Work> {
context.token.jwt.as_ref().ok_or(ThothError::Unauthorised)?;
let work = Work::from_id(&context.db, &data.work_id).unwrap();
context
Expand All @@ -1063,7 +1065,7 @@ impl MutationRoot {
work.can_update_imprint(&context.db)?;
}
let account_id = context.token.jwt.as_ref().unwrap().account_id(&context.db);
work.update(&context.db, &data, &account_id)
work.update_with_units(&context.db, data, &account_id, units)
.map_err(|e| e.into())
}

Expand Down Expand Up @@ -1455,12 +1457,32 @@ impl Work {
self.place.as_ref()
}

pub fn width(&self) -> Option<&i32> {
self.width.as_ref()
#[graphql(
description = "Width of the physical Work (in mm, cm or in)",
arguments(
units(
default = LengthUnit::default(),
description = "Unit of measurement in which to represent the width (mm, cm or in)",
),
)
)]
pub fn width(&self, units: LengthUnit) -> Option<f64> {
self.width
.map(|w| w.convert_units_from_to(&LengthUnit::Mm, &units))
}

pub fn height(&self) -> Option<&i32> {
self.height.as_ref()
#[graphql(
description = "Height of the physical Work (in mm, cm or in)",
arguments(
units(
default = LengthUnit::default(),
description = "Unit of measurement in which to represent the height (mm, cm or in)",
),
)
)]
pub fn height(&self, units: LengthUnit) -> Option<f64> {
self.height
.map(|h| h.convert_units_from_to(&LengthUnit::Mm, &units))
}

pub fn page_count(&self) -> Option<&i32> {
Expand Down
Loading

0 comments on commit 67491ab

Please sign in to comment.