Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ead4f1bf1 | |||
| 8d7bd7067e | |||
| db3e3ae291 |
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user