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)]
|
||||
pub(crate) struct JobOfferData {
|
||||
pub(crate) struct JobOfferViewData {
|
||||
id: String,
|
||||
status: JobOfferStatus,
|
||||
offering_party: String,
|
||||
|
|
@ -172,7 +172,7 @@ pub(crate) fn job_data<'i, I: Iterator<Item = (&'i str, &'i JobOffer<PathBuf>)>>
|
|||
req: &HttpRequest,
|
||||
offers: I,
|
||||
user: Option<&User>,
|
||||
) -> Vec<JobOfferData> {
|
||||
) -> Vec<JobOfferViewData> {
|
||||
let mut data: Vec<_> = offers
|
||||
.filter_map(|(id, offer)| match offer.to_real_data(id, req, user) {
|
||||
Ok(offer) => offer,
|
||||
|
|
@ -529,7 +529,7 @@ impl JobOffer<PathBuf> {
|
|||
id: &JobOfferId,
|
||||
req: &HttpRequest,
|
||||
confirmation_token: Option<&str>,
|
||||
) -> Result<JobOfferData, PresentationError> {
|
||||
) -> Result<JobOfferViewData, PresentationError> {
|
||||
self.to_data(id, req, true, None, confirmation_token)
|
||||
}
|
||||
|
||||
|
|
@ -558,7 +558,7 @@ impl JobOffer<PathBuf> {
|
|||
id: &JobOfferId,
|
||||
req: &HttpRequest,
|
||||
user: Option<&User>,
|
||||
) -> Result<Option<JobOfferData>, PresentationError> {
|
||||
) -> Result<Option<JobOfferViewData>, PresentationError> {
|
||||
let data = self.to_data(id, req, false, user, None)?;
|
||||
if user.is_none() && (data.expired || !data.published) {
|
||||
Ok(None)
|
||||
|
|
@ -574,7 +574,7 @@ impl JobOffer<PathBuf> {
|
|||
is_preview: bool,
|
||||
user: Option<&User>,
|
||||
confirmation_token: Option<&str>,
|
||||
) -> Result<JobOfferData, PresentationError> {
|
||||
) -> Result<JobOfferViewData, PresentationError> {
|
||||
let is_authenticated = user.is_some();
|
||||
|
||||
let is_expired = self.is_expired();
|
||||
|
|
@ -626,7 +626,7 @@ impl JobOffer<PathBuf> {
|
|||
None
|
||||
};
|
||||
|
||||
Ok(JobOfferData {
|
||||
Ok(JobOfferViewData {
|
||||
actions,
|
||||
id: id.to_string(),
|
||||
status: self.status.clone(),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use serde::Serialize;
|
|||
use serde_json::json;
|
||||
|
||||
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::SuccessRenderError;
|
||||
use crate::route::HTML_CONTENT;
|
||||
|
|
@ -18,9 +18,9 @@ struct ConfirmActions {
|
|||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct ConfirmJobOfferData {
|
||||
struct ConfirmJobOfferViewData {
|
||||
#[serde(flatten)]
|
||||
preview: JobOfferData,
|
||||
preview: JobOfferViewData,
|
||||
actions: ConfirmActions,
|
||||
is_reviewed: bool,
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ pub(crate) async fn confirm_joboffer_get(
|
|||
} else {
|
||||
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))?,
|
||||
actions: ConfirmActions {
|
||||
confirm_url: req
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue