features, cleanup and bug fixes #26
2 changed files with 10 additions and 10 deletions
rename types so its more clear that these are not storage formats
commit
c0e590babc
|
|
@ -117,7 +117,7 @@ impl SubmissionLimiter {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
pub(crate) struct JobOfferData {
|
pub(crate) struct JobOfferViewData {
|
||||||
id: String,
|
id: String,
|
||||||
status: JobOfferStatus,
|
status: JobOfferStatus,
|
||||||
offering_party: String,
|
offering_party: String,
|
||||||
|
|
@ -172,7 +172,7 @@ pub(crate) fn job_data<'i, I: Iterator<Item = (&'i str, &'i JobOffer<PathBuf>)>>
|
||||||
req: &HttpRequest,
|
req: &HttpRequest,
|
||||||
offers: I,
|
offers: I,
|
||||||
user: Option<&User>,
|
user: Option<&User>,
|
||||||
) -> Vec<JobOfferData> {
|
) -> Vec<JobOfferViewData> {
|
||||||
let mut data: Vec<_> = offers
|
let mut data: Vec<_> = offers
|
||||||
.filter_map(|(id, offer)| match offer.to_real_data(id, req, user) {
|
.filter_map(|(id, offer)| match offer.to_real_data(id, req, user) {
|
||||||
Ok(offer) => offer,
|
Ok(offer) => offer,
|
||||||
|
|
@ -529,7 +529,7 @@ impl JobOffer<PathBuf> {
|
||||||
id: &JobOfferId,
|
id: &JobOfferId,
|
||||||
req: &HttpRequest,
|
req: &HttpRequest,
|
||||||
confirmation_token: Option<&str>,
|
confirmation_token: Option<&str>,
|
||||||
) -> Result<JobOfferData, PresentationError> {
|
) -> Result<JobOfferViewData, PresentationError> {
|
||||||
self.to_data(id, req, true, None, confirmation_token)
|
self.to_data(id, req, true, None, confirmation_token)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -558,7 +558,7 @@ impl JobOffer<PathBuf> {
|
||||||
id: &JobOfferId,
|
id: &JobOfferId,
|
||||||
req: &HttpRequest,
|
req: &HttpRequest,
|
||||||
user: Option<&User>,
|
user: Option<&User>,
|
||||||
) -> Result<Option<JobOfferData>, PresentationError> {
|
) -> Result<Option<JobOfferViewData>, PresentationError> {
|
||||||
let data = self.to_data(id, req, false, user, None)?;
|
let data = self.to_data(id, req, false, user, None)?;
|
||||||
if user.is_none() && (data.expired || !data.published) {
|
if user.is_none() && (data.expired || !data.published) {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
|
@ -574,7 +574,7 @@ impl JobOffer<PathBuf> {
|
||||||
is_preview: bool,
|
is_preview: bool,
|
||||||
user: Option<&User>,
|
user: Option<&User>,
|
||||||
confirmation_token: Option<&str>,
|
confirmation_token: Option<&str>,
|
||||||
) -> Result<JobOfferData, PresentationError> {
|
) -> Result<JobOfferViewData, PresentationError> {
|
||||||
let is_authenticated = user.is_some();
|
let is_authenticated = user.is_some();
|
||||||
|
|
||||||
let is_expired = self.is_expired();
|
let is_expired = self.is_expired();
|
||||||
|
|
@ -626,7 +626,7 @@ impl JobOffer<PathBuf> {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(JobOfferData {
|
Ok(JobOfferViewData {
|
||||||
actions,
|
actions,
|
||||||
id: id.to_string(),
|
id: id.to_string(),
|
||||||
status: self.status.clone(),
|
status: self.status.clone(),
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use serde::Serialize;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
use crate::auth::User;
|
use crate::auth::User;
|
||||||
use crate::job_offers::JobOfferData;
|
use crate::job_offers::JobOfferViewData;
|
||||||
use crate::route::job_offer::error::ConfirmationResponseError;
|
use crate::route::job_offer::error::ConfirmationResponseError;
|
||||||
use crate::route::job_offer::error::ConfirmationResponseError::SuccessRenderError;
|
use crate::route::job_offer::error::ConfirmationResponseError::SuccessRenderError;
|
||||||
use crate::route::HTML_CONTENT;
|
use crate::route::HTML_CONTENT;
|
||||||
|
|
@ -18,9 +18,9 @@ struct ConfirmActions {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct ConfirmJobOfferData {
|
struct ConfirmJobOfferViewData {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
preview: JobOfferData,
|
preview: JobOfferViewData,
|
||||||
actions: ConfirmActions,
|
actions: ConfirmActions,
|
||||||
is_reviewed: bool,
|
is_reviewed: bool,
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +45,7 @@ pub(crate) async fn confirm_joboffer_get(
|
||||||
} else {
|
} else {
|
||||||
let user = User::current(&session).ok();
|
let user = User::current(&session).ok();
|
||||||
|
|
||||||
let job_offer = ConfirmJobOfferData {
|
let job_offer = ConfirmJobOfferViewData {
|
||||||
preview: job_offer.to_preview_data(id, &req, Some(req_token))?,
|
preview: job_offer.to_preview_data(id, &req, Some(req_token))?,
|
||||||
actions: ConfirmActions {
|
actions: ConfirmActions {
|
||||||
confirm_url: req
|
confirm_url: req
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue