Repository: DjangoGirls/djangogirls

Issue:
populate_database script is out-of-date
_From @MarysiaLowas on July 24, 2015 17:23_

Most probably populate_database script is out of date. I haven't run it but it's ages till we last updated it.

_Copied from original issue: djangogirlsjobs/djangogirls#66_



Discussion:
This script should be removed. It's not working any more and it's no needed at the moment.

Actually, the populate_database script is still working. However, it generates jobs and meetups with are already published but don't have any reviewer assigned to it. In a normal (manual) flow, such a situation is not possible. New jobs and meetups don't have any reviewer but the reviewer is assigned automatically during the "Assign" or "Restore" action. So the script behaviour can be misleading.


Resolving patch:
diff --git a/jobs/management/__init__.py b/jobs/management/__init__.py
deleted file mode 100644
diff --git a/jobs/management/commands/__init__.py b/jobs/management/commands/__init__.py
deleted file mode 100644
diff --git a/jobs/management/commands/populate_database.py b/jobs/management/commands/populate_database.py
deleted file mode 100644
--- a/jobs/management/commands/populate_database.py
+++ /dev/null
@@ -1,120 +0,0 @@
-from django.core.management.base import NoArgsCommand
-
-from jobs.models import Job, Meetup
-
-
-class Command(NoArgsCommand):
-    help = "Populates database with meetups and job offers."
-
-    def add_meetup(self, title, city, country, description, meetup_start_date, meetup_end_date):
-        meetup, created = Meetup.objects.get_or_create(
-            title=title,
-            contact_email='example@example.com',
-            city=city,
-            country=country,
-            description=description,
-            meetup_start_date=meetup_start_date,
-            meetup_end_date=meetup_end_date,
-            review_status=Meetup.READY_TO_PUBLISH,
-        )
-        return meetup
-
-    def add_job(self, title, company, website, cities, country, description):
-        job, created = Job.objects.get_or_create(
-            title=title,
-            company=company,
-            website=website,
-            contact_email='example@example.com',
-            cities=cities,
-            country=country,
-            description=description,
-            review_status=Meetup.READY_TO_PUBLISH,
-        )
-        return job
-
-    def handle_noargs(self, **options):
-        # Adding some meetups with future dates.
-        self.add_meetup(
-            title='Django Girls Warsaw',
-            city='Warsaw',
-            country='PL',
-            description='description',
-            meetup_start_date='2015-04-01',
-            meetup_end_date='2015-04-01'
-        )
-        self.add_meetup(
-            title='Women in Technology',
-            city='London',
-            country='GB',
-            description='description',
-            meetup_start_date='2015-05-15',
-            meetup_end_date='2015-05-15'
-        )
-        self.add_meetup(
-            title='Learn javascript',
-            city='Paris',
-            country='FR',
-            description='description',
-            meetup_start_date='2015-06-12',
-            meetup_end_date='2015-06-12',
-        )
-
-        self.add_meetup(
-            title='Python breakfast',
-            city='Berlin',
-            country='DE',
-            description='description',
-            meetup_start_date='2015-07-01',
-            meetup_end_date='2015-07-01',
-        )
-
-        self.add_meetup(
-            title='Girls Meetup',
-            city='New York',
-            country='US',
-            description='description',
-            meetup_start_date='2015-08-01',
-            meetup_end_date='2015-08-01'
-        )
-
-        # Adding some job offers.
-        self.add_job(
-            title='Intern',
-            company='Google',
-            website='http://www.google.pl/about/careers/students/',
-            cities='London',
-            country='GB',
-            description='description',
-        )
-
-        self.add_job(
-            title='Software Development Engineer - Paid Internship',
-            company='Amazon',
-            website='http://www.amazon.jobs/team-category/university-recruiting',
-            cities='Gdansk',
-            country='PL',
-            description='description',
-        )
-
-        self.add_job(
-            title='Software Engineer, Front End',
-            company='Digital Ocean',
-            website='https://careers.digitalocean.com/',
-            cities='New York',
-            country='US',
-            description='description',
-        )
-
-        def print_created_objects(model):
-            """Prints created objects on terminal."""
-            for created_object in model.objects.all():
-                self.stdout.write('-{0}'.format(created_object))
-
-        # Publishing meetups and job offers.
-        for meetup in Meetup.objects.filter(review_status=Meetup.READY_TO_PUBLISH):
-            meetup.publish()
-        for job in Job.objects.filter(review_status=Meetup.READY_TO_PUBLISH):
-            job.publish()
-
-        print_created_objects(Meetup)
-        print_created_objects(Job)


Test patch: