def delete_edit(edit_id): """This annotation is to delete an *edit* to an annotation because it contains illegal content. """ form = AreYouSureForm() edit = Edit.query.get_or_404(edit_id) redirect_url = generate_next( url_for('main.edit_history', annotation_id=edit.annotation_id)) if form.validate_on_submit(): if edit.current: edit.previous.current = True else: for e in edit.annotation.all_edits.order_by(Edit.num.desc()).all(): if e.num > edit.num: e.num -= 1 flash(f"Edit #{edit.num} of [{edit.annotation_id}] deleted.") db.session.delete(edit) db.session.commit() return redirect(redirect_url) text = """If you click submit the edit, all of the votes for the edit, and all of the reputation changes based on the edit being approved will be deleted. The edit numbers of all the subsequent edits will be decremented by one. It will therefore be as though the edit never even existed. The only reason for this is if there is illegal content in the edit. """ return render_template('forms/delete_check.html', title=f"Delete edit #{edit.num} of " f"[{edit.annotation_id}]", form=form, text=text)
def delete_annotation(annotation_id): """Delete an annotation. Like, full on remove it from the system. This route will be eliminated. Or it's security priveleges changed. The purpose of this route is for two different scenarios: 1. The annotation is useless/spam/etc. and should be eliminated. 2. The annotation is dangerous (illegal content, copyright violation, etc.) My inclination is to keep it for the latter, but use other methods for the former. """ form = AreYouSureForm() annotation = Annotation.query.get_or_404(annotation_id) redirect_url = generate_next( url_for('main.text_annotations', text_url=annotation.text.url)) if form.validate_on_submit(): for e in annotation.all_edits: e.tags = [] db.session.delete(annotation) db.session.commit() flash(f"Annotation [{annotation_id}] deleted.") return redirect(redirect_url) text = """If you click submit the annotation, all of the edits to the annotation, all of the votes to the edits, all of the votes to the annotation, and all of the reputation changes based on the annotation, will be deleted permanently. This is not something to take lightly. Unless there is illegal content associated with the annotation, you really ought to simply deactivate it. """ return render_template('forms/delete_check.html', title=f"Delete [{annotation_id}]", form=form, text=text)
def delete_tag_request(request_id): form = AreYouSureForm() tag_request = TagRequest.query.get_or_404(request_id) if not current_user == tag_request.requester: current_user.authorize('delete_tag_requests') redirect_url = url_for('requests.tag_request_index') if form.validate_on_submit(): db.session.delete(tag_request) db.session.commit() flash(f"Tag Request for {tag_request.tag} deleted.") return redirect(redirect_url) text = """If you click submit the text request and all of it's votes will be deleted permanently.""" return render_template('forms/delete_check.html', title=f"Delete Tag Request", form=form, text=text)
def anonymize_user(user_id): """Anonymize a user account (equivalent to deleting it).""" form = AreYouSureForm() user = User.query.get_or_404(user_id) redirect_url = url_for('user.profile', user_id=user.id) if form.validate_on_submit(): user.displayname = f'x_user{user.id}' user.email = f'{user.id}' user.password_hash = '***' user.about_me = '' db.session.commit() flash("Account anonymized.") return redirect(redirect_url) text = f"""If you click submit you will forcibly anonymize this user ({user.displayname}).""" return render_template('forms/delete_check.html', title="Are you sure?", form=form, text=text)
def delete_comment(annotation_id, comment_id): """Delete a comment.""" form = AreYouSureForm() comment = Comment.query.get_or_404(comment_id) redirect_url = generate_next(comment.url) if form.validate_on_submit(): comment.body = "[deleted]" db.session.commit() flash(f"Comment deleted.") return redirect(redirect_url) text = """This is to delete a comment. The only reason to delete a comment is if it is illegal content. It doesn't actually "delete" the comment, it just obliterates the content. """ return render_template('forms/delete_check.html', title=f"Delete Comment {comment_id}", form=form, text=text)
def delete_profile_check(): """Delete the user's profile (i.e., anonymize).""" form = AreYouSureForm() redirect_url = generate_next( url_for('user.profile', user_id=current_user.id)) if form.validate_on_submit(): current_user.displayname = f'x_user{current_user.id}' current_user.email = '{current_user.id}' current_user.password_hash = '***' current_user.about_me = '' db.session.commit() logout_user() flash("Account anonymized.") return redirect(redirect_url) text = f"""You have clicked the link to delete your account. This page serves as a double check to make sure that you’re really sure you want to delete your account. You will not be able to undo this. Annopedia is not like Facebook. We don’t secretly keep your personal information so you can reactivate your account later on. If you delete it, it’s done. Please note, however, that the account itself will not be expunged from our database. Annopedia is a collaborative effort, and we therefore reserve the right to retain all of your contributions. This deletion is an anonymization of your account. Your display name, email address, and about me will all be erased and anonymized. Every interaction you have ever made with the site will be associated with an account which cannot be logged into and whose display name will be `x_user_{current_user.id}` But you will never be able to log back in and retrieve your account. If you’re really sure about this, click the button “Yes, I’m sure.” Otherwise, press back in your browser, or _close_ your browser, or even pull the power cord from the back of your computer. Because if you click “Yes, I’m sure,” then your account is gone.""" return render_template('forms/delete_check.html', title="Are you sure?", form=form, text=text)