From d96f80185904d4e99e05c5eaa364f7f0caa72840 Mon Sep 17 00:00:00 2001 From: Sergio Delgado Quintero Date: Thu, 28 Sep 2023 09:31:47 +0100 Subject: [PATCH] Disable twitter publication of job offer due to Twitter API restrictions --- apps/jobs/models.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/apps/jobs/models.py b/apps/jobs/models.py index 72f28e1e..36caea41 100644 --- a/apps/jobs/models.py +++ b/apps/jobs/models.py @@ -38,16 +38,10 @@ class ActiveJobOfferManager(models.Manager): def get_queryset(self): today = datetime.date.today() - return ( - super() - .get_queryset() - .filter(approved=True) - .filter(valid_until__gte=today) - ) + return super().get_queryset().filter(approved=True).filter(valid_until__gte=today) class JobOffer(models.Model): - objects = models.Manager() # The default manager. actives = ActiveJobOfferManager() # Only the active jobs offer @@ -59,9 +53,7 @@ class Meta: employer = models.CharField("Ofertante", max_length=120) title = models.CharField("Nombre del puesto", max_length=220) description = models.TextField("Texto de la oferta", max_length=2000) - salary = models.CharField( - "Salario o rango salarial", max_length=80, blank=True - ) + salary = models.CharField("Salario o rango salarial", max_length=80, blank=True) contract_type = models.CharField( "Tipo de contrato", max_length=3, @@ -108,6 +100,7 @@ def save(self, *args, **kwargs): already_exists = self.pk is not None super().save(*args, **kwargs) if not already_exists and self.approved: - t = Twitter() + # tweepy.error.TweepError: [{'message': 'You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product', 'code': 453}] + # t = Twitter() msg = f'💼 Oferta de empleo: {self} {self.get_full_url()}' t.post(msg)