from django.forms.widgets import TextInput, Select, Textarea, CheckboxInput
from django.utils.safestring import mark_safe

class TextInputWidget(TextInput):
    def __init__(self):
        self.attrs = {"class": "form-control form-control-sm"}


class SelectWidget(Select):
    """
    not used, this widget does work, but we cannot order the choices by name
    """

    def __init__(self):
        attrs = {"class": "form-control custom-select custom-select-sm"}
        super().__init__(attrs=attrs)
        # super().choices = choices
        # self.choices = super().choices


class TextAreaWidget(Textarea):
    def __init__(self):
        self.attrs = {"class": "form-control", "rows": "3"}


class VolpianoAreaWidget(Textarea):
    def __init__(self):
        self.attrs = {
            "class": "form-control",
            "rows": "1.5",
            "style": "font-family: Volpiano; font-size: xx-large",
        }


class VolpianoInputWidget(TextInput):
    def __init__(self):
        self.attrs = {
            "class": "form-control form-control-sm",
            "style": "font-family: Volpiano; font-size: xx-large",
        }


class CheckboxWidget(CheckboxInput):
    pass


class AdminTextAreaWidget(Textarea):
    def __init__(self):
        self.attrs = {"class": "form-control", "rows": 10, "cols": 75}

    def render(self, name, value, attrs=None, renderer=None):
        return super().render(name, value, attrs=self.attrs) + mark_safe(
            '<span style="color: red; font-weight: bold;"> &nbsp;* </span>'
        )


class AdminTextInputWidget(TextInputWidget):
    def render(self, name, value, attrs=None, renderer=None):
        return super().render(name, value) + mark_safe(
            '<span style="color: red; font-weight: bold;"> &nbsp;* </span>'
        )

django/cantusdb_project/main_app/widgets.py
from django.forms.widgets import TextInput, Select, Textarea, CheckboxInput
from django.utils.safestring import mark_safe


class TextInputWidget(TextInput):
    def __init__(self):
        self.attrs = {"class": "form-control form-control-sm"}


class SelectWidget(Select):
    """
    not used, this widget does work, but we cannot order the choices by name
    """

    def __init__(self):
        attrs = {"class": "form-control custom-select custom-select-sm"}
        super().__init__(attrs=attrs)
        # super().choices = choices
        # self.choices = super().choices


class TextAreaWidget(Textarea):
    def __init__(self):
        self.attrs = {"class": "form-control", "rows": "3"}


class VolpianoAreaWidget(Textarea):
    def __init__(self):
        self.attrs = {
            "class": "form-control",
            "rows": "1.5",
            "style": "font-family: Volpiano; font-size: xx-large",
        }


class VolpianoInputWidget(TextInput):
    def __init__(self):
        self.attrs = {
            "class": "form-control form-control-sm",
            "style": "font-family: Volpiano; font-size: xx-large",
        }


class CheckboxWidget(CheckboxInput):
    pass


class AdminTextAreaWidget(Textarea):
    def __init__(self):
        self.attrs = {"class": "form-control", "rows": 10, "cols": 75}

    def render(self, name, value, attrs=None, renderer=None):
        return super().render(name, value, attrs=self.attrs) + mark_safe(
            '<span style="color: red; font-weight: bold;"> &nbsp;* </span>'
        )


class AdminTextInputWidget(TextInputWidget):
    def render(self, name, value, attrs=None, renderer=None):
        return super().render(name, value) + mark_safe(
            '<span style="color: red; font-weight: bold;"> &nbsp;* </span>'
        )

django/cantusdb_project/main_app/widgets.py
diff --git a/django/cantusdb_project/main_app/widgets.py b/django/cantusdb_project/main_app/widgets.py
index d39ff85ba..6c66153cd 100644
--- a/django/cantusdb_project/main_app/widgets.py
+++ b/django/cantusdb_project/main_app/widgets.py
@@ -1,6 +1,7 @@
 from django.forms.widgets import TextInput, Select, Textarea, CheckboxInput
 from django.utils.safestring import mark_safe
 
+
 class TextInputWidget(TextInput):
     def __init__(self):
         self.attrs = {"class": "form-control form-control-sm"}
diff --git a/docker-compose.yml b/docker-compose.yml
index ba468c704..c6bd06e80 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -11,6 +11,7 @@ services:
     env_file: ./config/envs/dev_env
     ports:
       - 3000:3000
+    restart: always
     depends_on:
       - postgres
 
@@ -26,6 +27,7 @@ services:
       - media_volume:/resources/media
       - certbot_data:/var/www/certbot/:ro
       - certificates:/etc/nginx/ssl/:ro
+    restart: always
     depends_on:
       - django
 
@@ -34,6 +36,7 @@ services:
     volumes:
       - certbot_data:/var/www/certbot/:rw
       - certificates:/etc/letsencrypt/:rw
+    restart: always
 
   postgres:
     build:
@@ -41,6 +44,7 @@ services:
     env_file: ./config/envs/dev_env
     volumes:
       - postgres_data:/var/lib/postgresql/data/
+    restart: always
 
 volumes:
   postgres_data:

we need to re-add a restart policy to docker-compose.yml
A recent change to docker-compose.yml removed the `restart: always` policy we added to our containers a couple of weeks ago. We should re-instate this.
