~sirodoht/mataroa

cdd53ffdcde98d757b781587116628f65ad5d6c1 — Theodore Keloglou 3 months ago 7c49b12
add post backups user option
M main/admin.py => main/admin.py +1 -0
@@ 47,6 47,7 @@ class UserAdmin(DjUserAdmin):
                    "comments_on",
                    "notifications_on",
                    "mail_export_on",
                    "post_backups_on",
                    "export_unsubscribe_key",
                    "webring_name",
                    "webring_prev_url",

A main/migrations/0083_user_post_backups_on.py => main/migrations/0083_user_post_backups_on.py +22 -0
@@ 0,0 1,22 @@
# Generated by Django 4.1 on 2022-08-21 21:50

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("main", "0082_snapshot"),
    ]

    operations = [
        migrations.AddField(
            model_name="user",
            name="post_backups_on",
            field=models.BooleanField(
                default=False,
                help_text="Enable/disable automatic post backups.",
                verbose_name="Snapshots On",
            ),
        ),
    ]

A main/migrations/0084_alter_user_post_backups_on.py => main/migrations/0084_alter_user_post_backups_on.py +22 -0
@@ 0,0 1,22 @@
# Generated by Django 4.1 on 2022-08-21 21:52

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("main", "0083_user_post_backups_on"),
    ]

    operations = [
        migrations.AlterField(
            model_name="user",
            name="post_backups_on",
            field=models.BooleanField(
                default=False,
                help_text="Enable/disable automatic post backups.",
                verbose_name="Post Backups On",
            ),
        ),
    ]

M main/models.py => main/models.py +5 -0
@@ 86,6 86,11 @@ class User(AbstractUser):
        help_text="Enable/disable auto emailing of account exports every month.",
        verbose_name="Mail export",
    )
    post_backups_on = models.BooleanField(
        default=False,
        help_text="Enable/disable automatic post backups.",
        verbose_name="Post Backups On",
    )
    export_unsubscribe_key = models.UUIDField(default=uuid.uuid4, unique=True)

    # webring related

M main/templates/assets/save-snapshot.js => main/templates/assets/save-snapshot.js +0 -3
@@ 52,7 52,4 @@ function initAutoSave() {
}

// init
// enable only for superusers for now
{% if request.user.is_superuser %}
initAutoSave();
{% endif %}

M main/templates/main/dashboard.html => main/templates/main/dashboard.html +1 -1
@@ 27,7 27,7 @@
        {% endif %}

        <br><a href="{% url 'analytic_list' %}">Analytics</a>
        {% if request.user.is_superuser %}
        {% if request.user.post_backups_on %}
        <br><a href="{% url 'snapshot_list' %}">Post Backups</a>
        {% endif %}
    </p>

M main/templates/main/post_form.html => main/templates/main/post_form.html +3 -0
@@ 82,6 82,9 @@
<script>
    {% include "assets/drag-and-drop-upload.js" %}
    {% include "assets/make-draft-button.js" %}

    {% if request.user.post_backups_on %}
    {% include "assets/save-snapshot.js" %}
    {% endif %}
</script>
{% endblock %}

M main/templates/main/snapshot_detail.html => main/templates/main/snapshot_detail.html +1 -1
@@ 29,7 29,7 @@
    </p>

    <p>
        <a href="{% url 'snapshot_list' %}">« Post Snapshots</a>
        <a href="{% url 'snapshot_list' %}">« Post Backups</a>
    </p>
</main>
{% endblock %}