Browse Source

Fix some things

pull/38/head
Dashie der otter 4 weeks ago
parent
commit
4b9fc7677b
Signed by: Dashie <dashie@sigpipe.me> 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"
22 22
 SERVER_NAME = AP_DOMAIN
23 23
 BASE_URL = "https://" + AP_DOMAIN
24 24
 # Should we enable federation
25
-AP_ENABLED = True
25
+AP_ENABLED = False
26
+# Federation notes:
27
+# ActivityPub support isn't finished and things like update or delete might not work at all
28
+# Activate federation at your own risks
26 29
 
27 30
 SQLALCHEMY_DATABASE_URI = \
28 31
     'postgresql+psycopg2://postgres@database/reel2bits'

+ 5
- 1
controllers/sound.py View File

@@ -181,9 +181,11 @@ def edit(username, soundslug):
181 181
 
182 182
         if federate_new:
183 183
             # Switched from private to public: initial federation
184
+
184 185
             from tasks import federate_new_sound
186
+            sound.activity_id = federate_new_sound(sound)
187
+            db.session.commit()
185 188
 
186
-            federate_new_sound(sound)
187 189
         else:
188 190
             # it's an update
189 191
             from tasks import send_update_sound
@@ -191,6 +193,8 @@ def edit(username, soundslug):
191 193
             send_update_sound(sound)
192 194
 
193 195
         return redirect(url_for("bp_sound.show", username=username, soundslug=sound.slug))
196
+    else:
197
+        form.private.data = sound.private
194 198
 
195 199
     if not sound.private:
196 200
         del form.private

+ 7
- 5
forms.py View File

@@ -98,8 +98,9 @@ class SoundUploadForm(Form):
98 98
     private = BooleanField(lazy_gettext("Private"), default=False)
99 99
 
100 100
     def validate_private(form, field):
101
-        if field.data is True and form.album.data.private is False:
102
-            raise ValidationError(lazy_gettext("Cannot put private sound in public album"))
101
+        if form.album.data:
102
+            if field.data is True and form.album.data.private is False:
103
+                raise ValidationError(lazy_gettext("Cannot put private sound in public album"))
103 104
 
104 105
     submit = SubmitField(lazy_gettext("Upload"))
105 106
 
@@ -118,9 +119,10 @@ class SoundEditForm(Form):
118 119
     private = BooleanField(lazy_gettext("Private"), default=False)
119 120
 
120 121
     def validate_private(form, field):
121
-        if field.data is True and form.album.data.private is False:
122
-            raise ValidationError(lazy_gettext("Cannot put private sound in public album"))
123
-        if field.data is True and form.sound.data.private is False:
122
+        if form.album.data:
123
+            if field.data is True and form.album.data.private is False:
124
+                raise ValidationError(lazy_gettext("Cannot put private sound in public album"))
125
+        if field.data is True and form.private.data is False:
124 126
             raise ValidationError(lazy_gettext("Published sound cannot be privatized again"))
125 127
 
126 128
     submit = SubmitField(lazy_gettext("Edit sound"))

Loading…
Cancel
Save