From 4a09f1b13d53d7ec97f4fd0a554a39d9afa68346 Mon Sep 17 00:00:00 2001 From: Chris Pawley Date: Sat, 4 Dec 2021 16:46:40 +0100 Subject: [PATCH 1/2] Update base.py --- wcivf/settings/base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/wcivf/settings/base.py b/wcivf/settings/base.py index f4534765f..92e294edf 100644 --- a/wcivf/settings/base.py +++ b/wcivf/settings/base.py @@ -55,7 +55,6 @@ "profiles", "feedback", "hustings", - "peoplecvs", "leaflets", "debug_toolbar", "django_extensions", From 155458392e6f5c043b7323629090954a2c8c276a Mon Sep 17 00:00:00 2001 From: Chris Pawley Date: Sat, 4 Dec 2021 16:57:17 +0100 Subject: [PATCH 2/2] Delete wcivf/apps/peoplecvs directory --- wcivf/apps/peoplecvs/README.md | 5 --- wcivf/apps/peoplecvs/__init__.py | 0 wcivf/apps/peoplecvs/management/__init__.py | 0 .../peoplecvs/management/commands/__init__.py | 0 .../management/commands/import_cvs.py | 39 ------------------ .../apps/peoplecvs/migrations/0001_initial.py | 40 ------------------- .../migrations/0002_auto_20170522_1324.py | 21 ---------- .../peoplecvs/migrations/0003_delete_cvs.py | 23 ----------- wcivf/apps/peoplecvs/migrations/__init__.py | 0 wcivf/apps/peoplecvs/models.py | 14 ------- 10 files changed, 142 deletions(-) delete mode 100644 wcivf/apps/peoplecvs/README.md delete mode 100644 wcivf/apps/peoplecvs/__init__.py delete mode 100644 wcivf/apps/peoplecvs/management/__init__.py delete mode 100644 wcivf/apps/peoplecvs/management/commands/__init__.py delete mode 100644 wcivf/apps/peoplecvs/management/commands/import_cvs.py delete mode 100644 wcivf/apps/peoplecvs/migrations/0001_initial.py delete mode 100644 wcivf/apps/peoplecvs/migrations/0002_auto_20170522_1324.py delete mode 100644 wcivf/apps/peoplecvs/migrations/0003_delete_cvs.py delete mode 100644 wcivf/apps/peoplecvs/migrations/__init__.py delete mode 100644 wcivf/apps/peoplecvs/models.py diff --git a/wcivf/apps/peoplecvs/README.md b/wcivf/apps/peoplecvs/README.md deleted file mode 100644 index c71bd2867..000000000 --- a/wcivf/apps/peoplecvs/README.md +++ /dev/null @@ -1,5 +0,0 @@ -Gets candidates' CVs from the [Democracy Club CVs](http://cv.democracyclub.org.uk/) site. - -(This app is called `peoplecvs`, rather than `cvs`, to avoid Sublime hiding it because it thinks it's a CVS-related file!) - -To load all CVs, run `python manage.py import_cvs` diff --git a/wcivf/apps/peoplecvs/__init__.py b/wcivf/apps/peoplecvs/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/wcivf/apps/peoplecvs/management/__init__.py b/wcivf/apps/peoplecvs/management/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/wcivf/apps/peoplecvs/management/commands/__init__.py b/wcivf/apps/peoplecvs/management/commands/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/wcivf/apps/peoplecvs/management/commands/import_cvs.py b/wcivf/apps/peoplecvs/management/commands/import_cvs.py deleted file mode 100644 index 8758a1017..000000000 --- a/wcivf/apps/peoplecvs/management/commands/import_cvs.py +++ /dev/null @@ -1,39 +0,0 @@ -from datetime import datetime - -from django.core.management.base import BaseCommand -from django.db import transaction -from django.utils import timezone as tz - -import requests - -from people.models import Person -from peoplecvs.models import CV - - -class Command(BaseCommand): - @transaction.atomic - def handle(self, **options): - url = "http://cv.democracyclub.org.uk/cvs.json" - req = requests.get(url) - results = req.json() - self.add_cvs(results) - - def add_cvs(self, results): - for result in results: - id = result["person_id"] - thumb_url = None - if "thumb" in result: - thumb_url = result["thumb"]["url"] - try: - person = Person.objects.get(ynr_id=id) - cv_obj, created = CV.objects.update_or_create(person=person) - cv_obj.url = result["url"] - cv_obj.thumb_url = thumb_url - d = datetime.strptime( - result["last_modified"], "%Y-%m-%dT%H:%M:%S" - ) - dt_aware = tz.make_aware(d, tz.get_current_timezone()) - cv_obj.last_modified = dt_aware - cv_obj.save() - except Person.DoesNotExist: - print("No person found with id %s" % result["person_id"]) diff --git a/wcivf/apps/peoplecvs/migrations/0001_initial.py b/wcivf/apps/peoplecvs/migrations/0001_initial.py deleted file mode 100644 index d4b8db327..000000000 --- a/wcivf/apps/peoplecvs/migrations/0001_initial.py +++ /dev/null @@ -1,40 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.7 on 2017-05-19 14:24 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [("people", "0018_auto_20170518_1255")] - - operations = [ - migrations.CreateModel( - name="CV", - fields=[ - ( - "id", - models.AutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ("url", models.URLField(blank=True, null=True)), - ("thumb_url", models.URLField(blank=True, null=True)), - ("last_modified", models.DateTimeField(blank=True, null=True)), - ( - "person", - models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, - to="people.Person", - ), - ), - ], - ) - ] diff --git a/wcivf/apps/peoplecvs/migrations/0002_auto_20170522_1324.py b/wcivf/apps/peoplecvs/migrations/0002_auto_20170522_1324.py deleted file mode 100644 index 75c3c3141..000000000 --- a/wcivf/apps/peoplecvs/migrations/0002_auto_20170522_1324.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10.7 on 2017-05-22 13:24 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [("peoplecvs", "0001_initial")] - - operations = [ - migrations.AlterField( - model_name="cv", - name="person", - field=models.OneToOneField( - on_delete=django.db.models.deletion.CASCADE, to="people.Person" - ), - ) - ] diff --git a/wcivf/apps/peoplecvs/migrations/0003_delete_cvs.py b/wcivf/apps/peoplecvs/migrations/0003_delete_cvs.py deleted file mode 100644 index 73b330951..000000000 --- a/wcivf/apps/peoplecvs/migrations/0003_delete_cvs.py +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by Django 2.2.20 on 2021-04-19 13:32 - -from django.apps.registry import apps -from django.db import migrations - - -def delete_cvs(app, schema_editor): - - CV = apps.get_model("peoplecvs", "CV") - CV.objects.all().delete() - - -class Migration(migrations.Migration): - - dependencies = [ - ("peoplecvs", "0002_auto_20170522_1324"), - ] - - operations = [ - migrations.RunPython( - code=delete_cvs, reverse_code=migrations.RunPython.noop - ) - ] diff --git a/wcivf/apps/peoplecvs/migrations/__init__.py b/wcivf/apps/peoplecvs/migrations/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/wcivf/apps/peoplecvs/models.py b/wcivf/apps/peoplecvs/models.py deleted file mode 100644 index b7ef08af4..000000000 --- a/wcivf/apps/peoplecvs/models.py +++ /dev/null @@ -1,14 +0,0 @@ -from django.db import models - -from people.models import Person - - -class CV(models.Model): - """ - A candidate's CV. - """ - - person = models.OneToOneField(Person, on_delete=models.CASCADE) - url = models.URLField(blank=True, null=True) - thumb_url = models.URLField(blank=True, null=True) - last_modified = models.DateTimeField(blank=True, null=True)