disable mastodon integration on debug
This commit is contained in:
parent
1884ac1d43
commit
5843c551b1
1 changed files with 5 additions and 1 deletions
|
|
@ -2,17 +2,21 @@ from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from mastodon import Mastodon
|
|
||||||
from .models import GovernmentPlanUpdate, GovernmentPlan
|
from .models import GovernmentPlanUpdate, GovernmentPlan
|
||||||
import re
|
import re
|
||||||
import html
|
import html
|
||||||
|
|
||||||
|
if not settings.DEBUG:
|
||||||
|
from mastodon import Mastodon
|
||||||
|
|
||||||
def strip_html_tags(text):
|
def strip_html_tags(text):
|
||||||
tag_re = re.compile(r'<[^>]+>')
|
tag_re = re.compile(r'<[^>]+>')
|
||||||
plain_text = tag_re.sub('', text)
|
plain_text = tag_re.sub('', text)
|
||||||
return html.unescape(plain_text)
|
return html.unescape(plain_text)
|
||||||
|
|
||||||
def post_to_mastodon(text):
|
def post_to_mastodon(text):
|
||||||
|
if settings.DEBUG:
|
||||||
|
return
|
||||||
mastodon = Mastodon(
|
mastodon = Mastodon(
|
||||||
access_token=settings.MASTODON_ACCESS_TOKEN,
|
access_token=settings.MASTODON_ACCESS_TOKEN,
|
||||||
api_base_url=settings.MASTODON_API_BASE_URL
|
api_base_url=settings.MASTODON_API_BASE_URL
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue