Skip to content

Feature - deletion of draft#354

Open
iambibhas wants to merge 12 commits intohasgeek:mainfrom
iambibhas:issue-337
Open

Feature - deletion of draft#354
iambibhas wants to merge 12 commits intohasgeek:mainfrom
iambibhas:issue-337

Conversation

@iambibhas
Copy link
Copy Markdown
Contributor

Fixes #337.

{% block content %}
<div class="sheet">
<div class="section first">
<h1>Delete this draft job post?</h1>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Delete this draft?"

form = Form()
if form.validate_on_submit():
post.close()
post.closed_datetime = datetime.utcnow()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noticed that this datetime can be set inside close() so moved there.

@iambibhas
Copy link
Copy Markdown
Contributor Author

@jace made the necessary changes and tested. works good.



class JobPost(BaseMixin, db.Model):
class JobPost(BaseMixin, db.Model):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there an extra space here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this got here. fixed it.

def delete(hashid, key):
post = JobPost.query.filter_by(hashid=hashid).options(db.load_only('id', 'status')).first_or_404()
if not post:
abort(404)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary because first_or_404() will do it for you.

if not post.admin_is(g.user):
abort(403)
if not post.is_draft():
return redirect(post.url_for(), code=303)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flash a message that this post must be withdrawn or closed.


def delete(self):
self.status = POSTSTATUS.DELETED
self.closed_datetime = datetime.utcnow()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use db.func.utcnow() in both cases.

@jace
Copy link
Copy Markdown
Member

jace commented Feb 21, 2018

@iambibhas where did we leave this one?

@iambibhas
Copy link
Copy Markdown
Contributor Author

@jace even I don't remember. This one was pending review I think. All the issues were fixed. Can get back to this once once we merge the statemanager one. Some workflow will change in this I guess.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 16, 2022

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Bibhas seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request - deletion of drafts

4 participants