Repository: learningequality/kolibri

Issue:
need ability to display photo credit for Kolibri home screen image
Thanks to @laurenlichtman who flagged this oversight on my part:

The image in the Kolibri home screen is missing the photographer's credit. His name is Thomas Van Den Driessche and we must credit him in order to be able to use the image. 

@jamalex suggestion: to have it along the version indicator, right after "usage and privacy"
<img width="712" alt="Screen Shot 2020-03-09 at 2 05 51 PM" src="https://user-images.githubusercontent.com/25229495/76259494-f0f8ec00-6212-11ea-84af-f30dbd7154d0.png">
Since there's a command that allows for the photos to be swapped, this should take an optional argument for the credit and it would only show up if one (photo credit) is set.

**Priority: high** 
(cc @indirectlylit @rtibbles) 
…


Required actions:
- [x] Add string to page: `Photo credit: {photographer_name}`
- [x] Display string after Usage and Privacy
- [x] Add photo credit name to the Kolibri theme https://github.com/learningequality/kolibri/blob/develop/kolibri/plugins/default_theme/kolibri_plugin.py#L53 and set value to `Thomas Van Den Driessche`
- [x] Extra cleanup: Delete this management command as it no longer actually affects the background image: https://github.com/learningequality/kolibri/blob/44bf1ed3591321f4b7ef7c4e5c6ceda8c01db7ae/kolibri/plugins/user/management/commands/background.py


Discussion:
This will require string updates (e.g. "Photo credit: {photographer_name}" and some nuanced changes to the management commands, so if the photographer is okay with leaving things as-is for another month or two, this would be much easier in 0.14. Let me know if there is more urgency
@indirectlylit No worries, we can punt it for v0.14. Let's just make it happen. Thank you! 
Note - the management command is now a noop, as its functionality has been overridden by the theme hook. So this would just require adding a name for photo credit to the theme hook, and using that in the frontend.

Ideally, we would also handle the case where the photo credit name is undefined, for old hooks that have not been updated.

Resolving patch:
diff --git a/kolibri/core/theme_hook.py b/kolibri/core/theme_hook.py
--- a/kolibri/core/theme_hook.py
+++ b/kolibri/core/theme_hook.py
@@ -38,6 +38,7 @@
 SIDE_NAV = "sideNav"
 APP_BAR = "appBar"
 BACKGROUND = "background"
+BACKGROUND_IMG_CREDIT = "backgroundImgCredit"
 SCRIM_OPACITY = "scrimOpacity"
 TITLE = "title"
 TITLE_STYLE = "titleStyle"
diff --git a/kolibri/plugins/default_theme/kolibri_plugin.py b/kolibri/plugins/default_theme/kolibri_plugin.py
--- a/kolibri/plugins/default_theme/kolibri_plugin.py
+++ b/kolibri/plugins/default_theme/kolibri_plugin.py
@@ -51,6 +51,7 @@ def theme(self):
             # sign-in page config
             theme_hook.SIGN_IN: {
                 theme_hook.BACKGROUND: static("background.jpg"),
+                theme_hook.BACKGROUND_IMG_CREDIT: "Thomas Van Den Driessche",
                 theme_hook.SCRIM_OPACITY: 0.7,
                 theme_hook.TITLE: None,  # use default: "Kolibri"
                 theme_hook.TOP_LOGO: {
diff --git a/kolibri/plugins/user/management/commands/background.py b/kolibri/plugins/user/management/commands/background.py
deleted file mode 100644
--- a/kolibri/plugins/user/management/commands/background.py
+++ /dev/null
@@ -1,72 +0,0 @@
-from __future__ import absolute_import
-from __future__ import print_function
-from __future__ import unicode_literals
-
-import hashlib
-import logging
-import os
-import shutil
-
-from django.conf import settings
-from django.core.management.base import BaseCommand
-
-from kolibri.core import theme_hook
-
-logger = logging.getLogger(__name__)
-
-
-class Command(BaseCommand):
-    def add_arguments(self, parser):
-        subparser = parser.add_subparsers(
-            dest="command", help="The following subcommands are available."
-        )
-        set_img_subparser = subparser.add_parser(
-            name="set",
-            cmd=self,
-            help="EXPERIMENTAL: Sets the login screen background image",
-        )
-        set_img_subparser.add_argument("new-image", type=str, help="Image file")
-        subparser.add_parser(name="unset", cmd=self, help="Return to default")
-
-    def handle(self, *args, **options):
-        bg_img = os.path.join(settings.MEDIA_ROOT, theme_hook.DEFAULT_BG_IMAGE_FILE)
-        md5_file = os.path.join(settings.MEDIA_ROOT, theme_hook.DEFAULT_BG_MD5_FILE)
-
-        if options["command"] == "set":
-            self.stdout.write(
-                self.style.WARNING(
-                    "\nCAUTION:\n"
-                    "Setting the background image is experimental functionality.\n"
-                    "Your changes may be reverted in a future update or upgrade.\n"
-                )
-            )
-
-            new_img = os.path.abspath(os.path.expanduser(options["new-image"]))
-            if not os.path.exists(new_img):
-                self.stderr.write(
-                    self.style.ERROR("\n{} does not exist.").format(
-                        options["new-image"]
-                    )
-                )
-                raise SystemExit(1)
-
-            if not os.path.exists(settings.MEDIA_ROOT):
-                os.mkdir(settings.MEDIA_ROOT)
-
-            shutil.copy(new_img, bg_img)
-            with open(bg_img, "rb") as img:
-                with open(md5_file, "w") as f:
-                    f.write(hashlib.md5(img.read()).hexdigest())
-
-        elif options["command"] == "unset":
-            if os.path.exists(bg_img):
-                os.remove(bg_img)
-            if os.path.exists(md5_file):
-                os.remove(md5_file)
-
-        else:
-            self.stderr.write(
-                self.style.ERROR(
-                    "Unrecognized command. Try running:\n  kolibri manage background --help"
-                ).format(options["command"])
-            )


Test patch: