[Draft] Implement Early deletion by Submitter #37 #38
4 changed files with 48 additions and 21 deletions
allow deleting job offers after confirmation
commit
508579fe63
|
|
@ -747,27 +747,29 @@ impl JobOffers {
|
|||
id: &JobOfferId,
|
||||
only_expired: bool,
|
||||
config: &ServerConfig,
|
||||
) -> Result<(), DeleteError> {
|
||||
) -> Result<Option<JobOffer<PathBuf>>, DeleteError> {
|
||||
use std::collections::btree_map::Entry;
|
||||
// we want to keep the guard around for the whole operation not
|
||||
// jut for the remove step, otherwise another thread might add a new offer under the same id,
|
||||
// while we have yet to delete the old one causing us to delete the new offer
|
||||
let mut guard = self.data.write().await;
|
||||
|
||||
match guard.entry(id.to_owned()) {
|
||||
Ok(match guard.entry(id.to_owned()) {
|
||||
Entry::Vacant(_) => {
|
||||
warn!("Tried to delete non-existent job-offer: {}", id)
|
||||
warn!("Tried to delete non-existent job-offer: {}", id);
|
||||
None
|
||||
}
|
||||
Entry::Occupied(entry) => {
|
||||
if !only_expired || entry.get().is_expired() {
|
||||
entry.remove();
|
||||
let result = entry.remove();
|
||||
let folder_path = JobOffer::<PathBuf>::folder_path(id, config);
|
||||
tokio::fs::remove_dir_all(folder_path).await?;
|
||||
Some(result)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ struct ConfirmJobOfferViewData {
|
|||
preview: JobOfferViewData,
|
||||
actions: ConfirmActions,
|
||||
is_reviewed: bool,
|
||||
is_confirmed: bool,
|
||||
}
|
||||
|
||||
pub(crate) const JOBOFFER_CONFIRM_ROUTE: &str = "joboffer_submission_confirm";
|
||||
|
|
@ -56,6 +57,7 @@ pub(crate) async fn confirm_joboffer_get(
|
|||
.to_string(),
|
||||
},
|
||||
is_reviewed: !job_offer.status.requires_review(),
|
||||
is_confirmed: !job_offer.status.requires_confirmation(),
|
||||
};
|
||||
|
||||
let data = json!({
|
||||
|
|
@ -138,12 +140,24 @@ pub(crate) async fn reject_joboffer_post(
|
|||
|
||||
if let Some(job_offer) = offers.get_offer(id).await {
|
||||
if job_offer.check_submitter_token(req_token) {
|
||||
// can't do this after delete as another request might race us between from and delete,
|
||||
// so we might not get a job offer back from delete, if the other request does the delete first
|
||||
let was_confirmed = !job_offer.status.requires_confirmation();
|
||||
|
||||
// early drop necessary as we can't hold a borrow to the job offer while deleting it
|
||||
drop(job_offer);
|
||||
offers.delete_offer(id, false, &config).await?;
|
||||
let job_offer = offers.delete_offer(id, false, &config).await?;
|
||||
|
||||
let title = if was_confirmed {
|
||||
"Job Offer Deletion Successful"
|
||||
} else {
|
||||
"Job Offer Retraction Successful"
|
||||
};
|
||||
|
||||
let data = json!({
|
||||
"base": crate::route::base(&req, &config, "Job Offer Retraction Successful")?,
|
||||
"base": crate::route::base(&req, &config, title)?,
|
||||
"user": user,
|
||||
"was_confirmed": was_confirmed,
|
||||
});
|
||||
|
||||
let body = hb
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ Bitte überprüfen Sie die Stellenausschreibung unter dem folgenden Link.
|
|||
|
||||
Dort können sie die Stellenausschreibung bestätigen oder zurückziehen.
|
||||
|
||||
Nach der Bestätigung kann der Link genutzt werden um die Stellenausschreibung vor Ablauf der Gültigkeit zu löschen.
|
||||
|
||||
Freundliche Grüße
|
||||
|
||||
Das Team der FS-InfMath Jobbörse
|
||||
|
|
|
|||
|
|
@ -7,18 +7,27 @@
|
|||
</div>
|
||||
|
||||
<div class="confirmation-actions">
|
||||
{{#> confirm-modal}}
|
||||
{{#*inline "id"}}{{job_offer.id}}{{/inline}}
|
||||
{{#*inline "kind"}}confirm{{/inline}}
|
||||
{{#*inline "action"}}Bestätigen{{#if job_offer.reviewed}} und veröffentlichen!{{/if}}{{/inline}}
|
||||
{{#*inline "formaction"}}{{job_offer.actions.confirm_url}}{{/inline}}
|
||||
{{/confirm-modal}}
|
||||
{{#> confirm-modal}}
|
||||
{{#*inline "id"}}{{job_offer.id}}{{/inline}}
|
||||
{{#*inline "kind"}}retract{{/inline}}
|
||||
{{#*inline "action"}}Zurückziehen{{/inline}}
|
||||
{{#*inline "formaction"}}{{job_offer.actions.retract_url}}{{/inline}}
|
||||
{{/confirm-modal}}
|
||||
{{#if job_offer.is_confirmed }}
|
||||
{{#> confirm-modal}}
|
||||
{{#*inline "id"}}{{job_offer.id}}{{/inline}}
|
||||
{{#*inline "kind"}}retract{{/inline}}
|
||||
{{#*inline "action"}}Löschen{{/inline}}
|
||||
{{#*inline "formaction"}}{{job_offer.actions.retract_url}}{{/inline}}
|
||||
{{/confirm-modal}}
|
||||
{{else}}
|
||||
{{#> confirm-modal}}
|
||||
{{#*inline "id"}}{{job_offer.id}}{{/inline}}
|
||||
{{#*inline "kind"}}confirm{{/inline}}
|
||||
{{#*inline "action"}}Bestätigen{{#if job_offer.is_reviewed}} und veröffentlichen!{{/if}}{{/inline}}
|
||||
{{#*inline "formaction"}}{{job_offer.actions.confirm_url}}{{/inline}}
|
||||
{{/confirm-modal}}
|
||||
{{#> confirm-modal}}
|
||||
{{#*inline "id"}}{{job_offer.id}}{{/inline}}
|
||||
{{#*inline "kind"}}retract{{/inline}}
|
||||
{{#*inline "action"}}Zurückziehen{{/inline}}
|
||||
{{#*inline "formaction"}}{{job_offer.actions.retract_url}}{{/inline}}
|
||||
{{/confirm-modal}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
{{/base}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue