Skip to content

Commit

Permalink
Disable twitter publication of job offer due to Twitter API restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
sdelquin committed Sep 28, 2023
1 parent 6a6c070 commit d96f801
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions apps/jobs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand Down Expand Up @@ -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)

0 comments on commit d96f801

Please sign in to comment.