Browse Source

WIP groundwork for data downloads creation

Rafał Pitoń 7 years ago
parent
commit
7ef3643f39

+ 4 - 1
.gitignore

@@ -71,4 +71,7 @@ venv/
 /media/
 /media/
 /static/
 /static/
 /userdata/
 /userdata/
-/manage.py
+<<<<<<< HEAD
+/manage.py
+=======
+>>>>>>> c92db2d... WIP groundwork for data downloads creation

+ 6 - 1
misago/conf/defaults.py

@@ -39,7 +39,12 @@ MISAGO_ANONYMOUS_USERNAME = "Ghost"
 # Enables users to learn what data about them is being held by the site without having to contact
 # Enables users to learn what data about them is being held by the site without having to contact
 # site's administrators.
 # site's administrators.
 
 
-MISAGO_ENABLE_DOWNLOAD_OWN_DATA = False
+MISAGO_ENABLE_DOWNLOAD_OWN_DATA = True
+
+# Path to the directory that Misago should use to prepare user data downloads.
+# Should not be accessible from internet.
+
+MISAGO_USER_DATA_DOWNLOADS_WORKING_DIR = None
 
 
 
 
 # Allow users to delete their accounts
 # Allow users to delete their accounts

+ 5 - 0
misago/project_template/project_name/settings.py

@@ -162,6 +162,11 @@ DEFAULT_FROM_EMAIL = 'Forums <%s>' % EMAIL_HOST_USER
 
 
 MISAGO_ENABLE_DOWNLOAD_OWN_DATA = True
 MISAGO_ENABLE_DOWNLOAD_OWN_DATA = True
 
 
+# Path to the directory that Misago should use to prepare user data downloads.
+# Should not be accessible from internet.
+
+MISAGO_USER_DATA_DOWNLOADS_WORKING_DIR = os.path.join(BASE_DIR, 'userdata')
+
 
 
 # Allow users to delete their accounts
 # Allow users to delete their accounts
 # Lets users delete their own account on the site without having to contact site administrators.
 # Lets users delete their own account on the site without having to contact site administrators.

+ 3 - 0
misago/project_template/userdata/README.txt

@@ -0,0 +1,3 @@
+This directory is used by Misago to prepare user data downloads.
+
+Make sure it's not accessible from internet.

+ 19 - 0
misago/users/management/commands/processuserdatadownloads.py

@@ -0,0 +1,19 @@
+from django.contrib.auth import get_user_model
+from django.core.management.base import BaseCommand, CommandError
+
+from misago.conf import settings
+from misago.core.pgutils import chunk_queryset
+from misago.users.models import DataDownload
+
+UserModel = get_user_model()
+
+
+class Command(BaseCommand):
+    help = "Processes user data downloads."
+
+    def handle(self, *args, **options):
+        if not settings.MISAGO_USER_DATA_DOWNLOADS_WORKING_DIR:
+            self.stdout.write(
+                "Data downloads working directory has to be set for this feature to work.")
+            return
+