Skip to content

Commit

Permalink
(settings) populate review app after successful deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Apr 17, 2024
1 parent 3fff5ce commit 69cf658
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
4 changes: 3 additions & 1 deletion clevercloud/review_app_after_succes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ echo "Activate virtualenv"
source $HOME/venv/bin/activate

echo "Loading data"
python manage.py loaddata fixtures/validation_fixtures.json
python manage.py loaddata fixtures/forum_permissions_fixtures.json
python manage.py populate


47 changes: 47 additions & 0 deletions lacommunaute/forum/management/commands/populate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import sys

from django.contrib.auth.hashers import make_password
from django.core.management.base import BaseCommand
from django.db import connection

from lacommunaute.event.factories import EventFactory
from lacommunaute.forum.factories import CategoryForumFactory, ForumFactory
from lacommunaute.forum_conversation.factories import AnonymousTopicFactory, PostFactory, TopicFactory
from lacommunaute.users.factories import UserFactory


class Command(BaseCommand):
help = "hydratation d'un site de validation"

def handle(self, *args, **options):
UserFactory(username="communaute", password=make_password("password"))
sys.stdout.write("superuser created\n")

forum = ForumFactory(name="Espace d'échanges", with_public_perms=True)
TopicFactory.create_batch(20, forum=forum, with_post=True)
TopicFactory.create_batch(
3, forum=forum, with_post=True, with_tags=["Pirmadienis", "Poniedziałek", "Lundi", "Montag"]
)
TopicFactory(forum=forum, with_post=True, with_certified_post=True)
AnonymousTopicFactory.create_batch(2, forum=forum, with_post=True)
PostFactory.create_batch(3, topic=TopicFactory(forum=forum, with_post=True))
sys.stdout.write("public forum created\n")

for i in range(1, 3):
parent = CategoryForumFactory(with_public_perms=True, name=f"Thème {i}")
for j in range(1, 3):
TopicFactory.create_batch(
2, forum=ForumFactory(parent=parent, with_public_perms=True, name=f"Fiche {i}{j}"), with_post=True
)
sys.stdout.write("documentation created\n")

EventFactory.create_batch(5)
sys.stdout.write("events created\n")

# refresh materialized view
with connection.cursor() as cursor:
cursor.execute("REFRESH MATERIALIZED VIEW search_commonindex")
sys.stdout.write("search index refreshed\n")

sys.stdout.write("that's all folks!")
sys.stdout.flush()

0 comments on commit 69cf658

Please sign in to comment.