3 Commits

Author SHA1 Message Date
Aarni Halinen 5ead4f1bf1 fix autohide filtering for feed 2022-01-14 12:55:25 +02:00
Aarni Halinen 8d7bd7067e remove TG_BOT_TOKEN 2022-01-14 00:14:32 +02:00
Aarni Halinen db3e3ae291 remove TG_BOT_TOKEN 2022-01-14 00:14:13 +02:00
6 changed files with 7 additions and 25 deletions
-1
View File
@@ -3,7 +3,6 @@ SENTRY_DSN=
HOST=api.dev.sahkoinsinoorikilta.fi
DEBUG=True
SECRET_KEY=7p$85^4ibb^p4-=vs44b7!y0e-zemugze18@a#30&71=a8)dp(
TG_BOT_TOKEN=
DB_NAME=postgres
DB_USER=postgres
DB_PASSWD=postgres
-1
View File
@@ -3,7 +3,6 @@ DEPLOY_ENV=local
HOST=localhost
DEBUG=True
SECRET_KEY=7p$85^4ibb^p4-=vs44b7!y0e-zemugze18@a#30&71=a8)dp(
TG_BOT_TOKEN=
DB_NAME=postgres
DB_USER=postgres
DB_PASSWD=postgres
-3
View File
@@ -4,9 +4,6 @@
if test -f "$SECRET_KEY_FILE"; then
export SECRET_KEY=$(cat $SECRET_KEY_FILE)
fi
if test -f "$TG_BOT_TOKEN_FILE"; then
export TG_BOT_TOKEN=$(cat $TG_BOT_TOKEN_FILE)
fi
if test -f "$EMAIL_API_KEY_FILE"; then
export EMAIL_API_KEY=$(cat $EMAIL_API_KEY_FILE)
fi
-3
View File
@@ -58,9 +58,6 @@ DEFAULT_EMAIL_FROM = "SIK"
DEFAULT_EMAIL_FROM_ADDR = "noreply@sahkoinsinoorikilta.fi"
ENABLE_AUTOMATIC_EMAILS = True
# Token for Telegram bot
TELEGRAM_BOT_TOKEN = os.getenv("TG_BOT_TOKEN", "<tg token>")
# Database settings
# Only uncomment if default settings in base.py are not ok
-4
View File
@@ -32,20 +32,16 @@ services:
- DB_PORT=5432
- DB_SSL=True
- SECRET_KEY_FILE=/run/secrets/BACKEND_SECRET_KEY
- TG_BOT_TOKEN_FILE=/run/secrets/BACKEND_TG_BOT_TOKEN
- DB_PASSWD_FILE=/run/secrets/BACKEND_DB_PASSWD
- EMAIL_API_KEY_FILE=/run/secrets/BACKEND_EMAIL_API_KEY
secrets:
- BACKEND_SECRET_KEY
- BACKEND_TG_BOT_TOKEN
- BACKEND_DB_PASSWD
- BACKEND_EMAIL_API_KEY
secrets:
BACKEND_SECRET_KEY:
external: true
BACKEND_TG_BOT_TOKEN:
external: true
BACKEND_DB_PASSWD:
external: true
BACKEND_EMAIL_API_KEY:
+7 -13
View File
@@ -281,22 +281,16 @@ class FeedViewSet(ModelViewSet):
def get_queryset(self):
if self.request.user.is_authenticated:
return Feed.objects.filter(deleted=False).order_by("-publish_time")
objs = Feed.objects.filter(deleted=False)
else:
objs = Feed.objects.filter(deleted=False, visible=True).order_by(
"-publish_time"
objs = Feed.objects.filter(
deleted=False, visible=True, publish_time__lt=timezone.now()
)
objs = objs.filter(autohide_enabled=False) | objs.filter(autohide_enabled=True, autohide__gt=timezone.now())
# TODO: Bad filtering. Rewrite!
result_ids = []
for obj in objs:
if obj.autohide_enabled:
if obj.autohide > timezone.now():
result_ids.append(obj.id)
else:
result_ids.append(obj.id)
return Feed.objects.filter(id__in=result_ids).order_by("-publish_time")
return objs.order_by(
"-publish_time"
)
def destroy(self, request, pk=None, *args, **kwargs):
try: