Browse Source

Fix some things

pull/38/head
Dashie der otter 11 months ago
parent
commit
4b9fc7677b
Signed by: dashie <rhaamo@leloop.org> GPG Key ID: C2D57B325840B755
3 changed files with 16 additions and 7 deletions
  1. +4
    -1
      config.py.sample
  2. +5
    -1
      controllers/sound.py
  3. +7
    -5
      forms.py

+ 4
- 1
config.py.sample View File

@@ -22,7 +22,10 @@ AP_DOMAIN = "localhost"
SERVER_NAME = AP_DOMAIN
BASE_URL = "https://" + AP_DOMAIN
# Should we enable federation
AP_ENABLED = True
AP_ENABLED = False
# Federation notes:
# ActivityPub support isn't finished and things like update or delete might not work at all
# Activate federation at your own risks

SQLALCHEMY_DATABASE_URI = \
'postgresql+psycopg2://postgres@database/reel2bits'


+ 5
- 1
controllers/sound.py View File

@@ -181,9 +181,11 @@ def edit(username, soundslug):

if federate_new:
# Switched from private to public: initial federation

from tasks import federate_new_sound
sound.activity_id = federate_new_sound(sound)
db.session.commit()

federate_new_sound(sound)
else:
# it's an update
from tasks import send_update_sound
@@ -191,6 +193,8 @@ def edit(username, soundslug):
send_update_sound(sound)

return redirect(url_for("bp_sound.show", username=username, soundslug=sound.slug))
else:
form.private.data = sound.private

if not sound.private:
del form.private


+ 7
- 5
forms.py View File

@@ -98,8 +98,9 @@ class SoundUploadForm(Form):
private = BooleanField(lazy_gettext("Private"), default=False)

def validate_private(form, field):
if field.data is True and form.album.data.private is False:
raise ValidationError(lazy_gettext("Cannot put private sound in public album"))
if form.album.data:
if field.data is True and form.album.data.private is False:
raise ValidationError(lazy_gettext("Cannot put private sound in public album"))

submit = SubmitField(lazy_gettext("Upload"))

@@ -118,9 +119,10 @@ class SoundEditForm(Form):
private = BooleanField(lazy_gettext("Private"), default=False)

def validate_private(form, field):
if field.data is True and form.album.data.private is False:
raise ValidationError(lazy_gettext("Cannot put private sound in public album"))
if field.data is True and form.sound.data.private is False:
if form.album.data:
if field.data is True and form.album.data.private is False:
raise ValidationError(lazy_gettext("Cannot put private sound in public album"))
if field.data is True and form.private.data is False:
raise ValidationError(lazy_gettext("Published sound cannot be privatized again"))

submit = SubmitField(lazy_gettext("Edit sound"))


Loading…
Cancel
Save