Giter VIP home page Giter VIP logo

Comments (9)

simonw avatar simonw commented on August 21, 2024

I'm going to optionally use Django auth groups for this, if they are defined.

I think a select box for "who can view" and a select box for "who can edit" will work. Following options:

  • Anyone (available for view but not for edit)
  • Only me (effectively private dashboards)
  • Logged in users
  • Staff users
  • Super users
  • Users in group X (one option for each group)

from django-sql-dashboard.

simonw avatar simonw commented on August 21, 2024

I'm going to add six columns to Dashboard for this:

  • created_by - foreign key to User
  • created_at - datetime
  • view_policy - enum
  • edit_policy - enum
  • view_group - nullable foreign key to Group
  • edit_group - nullable foreign key to Group

from django-sql-dashboard.

simonw avatar simonw commented on August 21, 2024

The policy enums will cover:

  • public (not for view, just edit)
  • creator
  • loggedin_users
  • group
  • staff
  • superusers

from django-sql-dashboard.

simonw avatar simonw commented on August 21, 2024

Another view permission option: unlisted - available to the public but only if they know the dashboard URL.

These ones won't be shown on the /dashboard/ index page and will have robots SEO exclusion.

from django-sql-dashboard.

simonw avatar simonw commented on August 21, 2024

Model changes in the admin (I customized the admin fieldsets):

Mozilla_Firefox

from django-sql-dashboard.

simonw avatar simonw commented on August 21, 2024

class Dashboard(models.Model):
slug = models.SlugField(unique=True)
title = models.CharField(blank=True, max_length=128)
description = models.TextField(blank=True)
created_by = models.ForeignKey(
settings.AUTH_USER_MODEL,
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="created_dashboards",
)
created_at = models.DateTimeField(default=timezone.now())
class ViewPolicies(models.TextChoices):
PRIVATE = ("private", "Private")
PUBLIC = ("public", "Public")
UNLISTED = ("unlisted", "Unlisted")
LOGGEDIN = ("loggedin", "Logged-in users")
GROUP = ("group", "Users in group")
STAFF = ("staff", "Staff users")
SUPERUSER = ("superuser", "Superusers")
class EditPolicies(models.TextChoices):
PRIVATE = ("private", "Private")
LOGGEDIN = ("loggedin", "Logged-in users")
GROUP = ("group", "Users in group")
STAFF = ("staff", "Staff users")
SUPERUSER = ("superuser", "Superusers")
# Permissions
view_policy = models.CharField(
max_length=10,
choices=ViewPolicies.choices,
default=ViewPolicies.PRIVATE,
)
edit_policy = models.CharField(
max_length=10,
choices=EditPolicies.choices,
default=EditPolicies.PRIVATE,
)
view_group = models.ForeignKey(
"auth.Group",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="can_view_dashboards",
)
edit_group = models.ForeignKey(
"auth.Group",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="can_edit_dashboards",
)

from django-sql-dashboard.

simonw avatar simonw commented on August 21, 2024

I'm going to change created_by to owned_by since that makes it clear that it's OK for a user to "transfer ownership" of a dashboard to someone else.

from django-sql-dashboard.

simonw avatar simonw commented on August 21, 2024

Next steps: get the dashboards to obey these permissions, with comprehensive tests. Editing can still happen through the admin interface for the moment.

Dashboards should include a visible note that explains who is allowed to edit or view the dashboard.

from django-sql-dashboard.

simonw avatar simonw commented on August 21, 2024

The remaining edit work will take place in #44.

from django-sql-dashboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.