Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task: Content Spacing Correction #801

Merged
merged 10 commits into from
Oct 5, 2023
2 changes: 2 additions & 0 deletions src/task_queue/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from task_queue.events_nudge.cadmin_events_nudge import send_events_nudge
from task_queue.events_nudge.user_event_nudge import prepare_user_events_nudge
from task_queue.nudges.postmark_sender_signature import collect_and_create_signatures
from task_queue.nudges.contents_spacing_correction import correct_contents_spacing
abdullai-t marked this conversation as resolved.
Show resolved Hide resolved
from task_queue.views import super_admin_nudge, create_snapshots, send_admin_mou_notification

"""
Expand All @@ -19,4 +20,5 @@
"User Event Nudge": prepare_user_events_nudge,
"Create Community Snapshots": create_snapshots,
"Postmark Sender Signature": collect_and_create_signatures,
"Correct Contents Spacing": correct_contents_spacing
}
44 changes: 44 additions & 0 deletions src/task_queue/nudges/contents_spacing_correction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from database.models import Action, Event, Testimonial


def correct_spacing_in_actions():
actions = Action.objects.filter(is_deleted=False)
for action in actions:
about = action.about.replace("<p><br></p>", "").replace("<p>.</p>", "").replace("<p>&nbsp;</p>", "")
deep_dive = action.deep_dive.replace("<p><br></p>", "").replace("<p>.</p>", "").replace("<p>&nbsp;</p>", "")
action.about = about
action.deep_dive = deep_dive
action.save()
return actions.count()



def correct_spacing_in_events():
events = Event.objects.filter(is_deleted=False)
for event in events:
description = event.description.replace("<p><br></p>", "").replace("<p>.</p>", "").replace("<p>&nbsp;</p>", "")
event.description = description
event.save()
return events.count()


def correct_spacing_in_testimonials():
testimonials = Testimonial.objects.filter(is_deleted=False)
for testimonial in testimonials:
body = testimonial.body.replace("<p><br></p>", "").replace("<p>.</p>", "").replace("<p>&nbsp;</p>", "")
testimonial.body = body
testimonial.save()
return testimonials.count()

def correct_contents_spacing():
abdullai-t marked this conversation as resolved.
Show resolved Hide resolved
actions = correct_spacing_in_actions()
print(f"==Corrected {actions} Actions spacing==")
events = correct_spacing_in_events()
print(f"==Corrected {events} Actions spacing==")
testimonials = correct_spacing_in_testimonials()
print(f"==Corrected {testimonials} Actions spacing==")
return True