Add django-guardian for object-level permissions

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-06-26 21:30:45 -07:00
parent d931f52f01
commit 29dff20db9
4 changed files with 29 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ django = "*"
pillow = "*"
django-hcaptcha = "*"
django-environ = "*"
django-guardian = "*"
[dev-packages]
mypy = "*"

22
Pipfile.lock generated
View File

@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "6b614acd169f2a3bcb689616de53fb77e5c97e078c338b86806b7bc7cdf9b48d"
"sha256": "a71e0de66e9b1b37118b78315b96e0469e01b88a3fb67e86b78686500e178c54"
},
"pipfile-spec": 6,
"requires": {
@@ -26,19 +26,27 @@
},
"django": {
"hashes": [
"sha256:815b1c3e1c1379cca1c54cc7202ee86df006f52b94560b46ea0b19f162c9474a",
"sha256:91980d3b327e38e44c2bef0af86d624a57adbd5f1c96f43acf150396770caf01"
"sha256:55ea3e07df2eb3994b7261d743c111e4c27a56ca1285eb762dba07432ebe4039",
"sha256:ec22c3e909af402281ef1dea69cbbc42b43b9ac9379df2914e0a7b85597242d6"
],
"index": "pypi",
"version": "==4.1a1"
"version": "==4.1b1"
},
"django-environ": {
"hashes": [
"sha256:42593bee519a527602a467c7b682aee1a051c2597f98c45f4f4f44169ecdb6e5",
"sha256:6f0bc902b43891656b20486938cba0861dc62892784a44919170719572a534cb"
"sha256:bff5381533056328c9ac02f71790bd5bf1cea81b1beeb648f28b81c9e83e0a21",
"sha256:f21a5ef8cc603da1870bbf9a09b7e5577ab5f6da451b843dbcc721a7bca6b3d9"
],
"index": "pypi",
"version": "==0.8.1"
"version": "==0.9.0"
},
"django-guardian": {
"hashes": [
"sha256:440ca61358427e575323648b25f8384739e54c38b3d655c81d75e0cd0d61b697",
"sha256:c58a68ae76922d33e6bdc0e69af1892097838de56e93e78a8361090bcd9f89a0"
],
"index": "pypi",
"version": "==2.4.0"
},
"django-hcaptcha": {
"hashes": [

View File

@@ -331,3 +331,10 @@ class BanTemplate(models.Model):
return f"/{self.board.url}/ - {self.name}"
else:
return self.name
class Capcode(models.Model):
# Content to display *before* the capcoded user's name.
prefix = models.CharField(max_length=100)
# Content to display *after* the capcoded user's name.
suffix = models.CharField(max_length=100)

View File

@@ -42,6 +42,7 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"guardian",
"board",
]
@@ -75,6 +76,11 @@ TEMPLATES = [
WSGI_APPLICATION = "threadchat.wsgi.application"
AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend",
"guardian.backends.ObjectPermissionBackend",
)
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases