Misc v3 linear tasks (#767)

* v3_reroute 404 error

* hash change

* fixed issue with error conversion

* added new model confirmation tests
+ title name change

* renaming, fields

* owner; test changes

* clippy prepare

* fmt

* merge fixes

* clippy

* working merge

* revs

* merge fixes
This commit is contained in:
Wyatt Verchere
2023-12-01 19:15:00 -08:00
committed by GitHub
parent 2d92b08404
commit a70df067bc
119 changed files with 2897 additions and 1334 deletions

View File

@@ -10,7 +10,7 @@ use crate::database::models::{version_item, DatabaseError};
use crate::database::redis::RedisPool;
use crate::models::ids::{ProjectId, VersionId};
use crate::models::projects::{
Dependency, GalleryItem, License, Link, Loader, ModeratorMessage, MonetizationStatus, Project,
Dependency, License, Link, Loader, ModeratorMessage, MonetizationStatus, Project,
ProjectStatus, Version, VersionFile, VersionStatus, VersionType,
};
use crate::models::threads::ThreadId;
@@ -63,7 +63,7 @@ pub struct LegacyProject {
pub wiki_url: Option<String>,
pub discord_url: Option<String>,
pub donation_urls: Option<Vec<DonationLink>>,
pub gallery: Vec<GalleryItem>,
pub gallery: Vec<LegacyGalleryItem>,
pub color: Option<u32>,
pub thread_id: ThreadId,
pub monetization_status: MonetizationStatus,
@@ -151,12 +151,12 @@ impl LegacyProject {
id: data.id,
slug: data.slug,
project_type,
team: data.team,
team: data.team_id,
organization: data.organization,
title: data.title,
description: data.description,
body: data.body,
body_url: data.body_url,
title: data.name,
description: data.summary, // V2 description is V3 summary
body: data.description, // V2 body is V3 description
body_url: None, // Always None even in V2
published: data.published,
updated: data.updated,
approved: data.approved,
@@ -177,7 +177,11 @@ impl LegacyProject {
wiki_url,
discord_url,
donation_urls,
gallery: data.gallery,
gallery: data
.gallery
.into_iter()
.map(LegacyGalleryItem::from)
.collect(),
color: data.color,
thread_id: data.thread_id,
monetization_status: data.monetization_status,
@@ -317,7 +321,7 @@ impl From<Version> for LegacyVersion {
name: data.name,
version_number: data.version_number,
changelog: data.changelog,
changelog_url: data.changelog_url,
changelog_url: None, // Always None even in V2
date_published: data.date_published,
downloads: data.downloads,
version_type: data.version_type,
@@ -332,6 +336,29 @@ impl From<Version> for LegacyVersion {
}
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct LegacyGalleryItem {
pub url: String,
pub featured: bool,
pub name: Option<String>,
pub description: Option<String>,
pub created: DateTime<Utc>,
pub ordering: i64,
}
impl LegacyGalleryItem {
fn from(data: crate::models::projects::GalleryItem) -> Self {
Self {
url: data.url,
featured: data.featured,
name: data.name,
description: data.description,
created: data.created,
ordering: data.ordering,
}
}
}
#[derive(Serialize, Deserialize, Validate, Clone, Eq, PartialEq)]
pub struct DonationLink {
pub id: String,