diff options
author | Jesús <heckyel@hyperbola.info> | 2022-01-13 18:08:28 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2022-01-13 18:08:28 -0500 |
commit | 4317b0ba5d614fb6f9f3d3ee333848e9774700ba (patch) | |
tree | f474806ce968874db270926dcb0399b7f3139d18 /django/social | |
parent | b77c06257f9b650e2274c7dcb8937c237353c64d (diff) | |
download | personal-site-4317b0ba5d614fb6f9f3d3ee333848e9774700ba.tar.lz personal-site-4317b0ba5d614fb6f9f3d3ee333848e9774700ba.tar.xz personal-site-4317b0ba5d614fb6f9f3d3ee333848e9774700ba.zip |
Add docker support
Diffstat (limited to 'django/social')
-rw-r--r-- | django/social/__init__.py | 0 | ||||
-rw-r--r-- | django/social/admin.py | 17 | ||||
-rw-r--r-- | django/social/apps.py | 6 | ||||
-rw-r--r-- | django/social/migrations/__init__.py | 0 | ||||
-rw-r--r-- | django/social/models.py | 34 | ||||
-rw-r--r-- | django/social/processors.py | 9 | ||||
-rw-r--r-- | django/social/tests.py | 3 | ||||
-rw-r--r-- | django/social/views.py | 3 |
8 files changed, 72 insertions, 0 deletions
diff --git a/django/social/__init__.py b/django/social/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/django/social/__init__.py diff --git a/django/social/admin.py b/django/social/admin.py new file mode 100644 index 0000000..3084240 --- /dev/null +++ b/django/social/admin.py @@ -0,0 +1,17 @@ +from django.contrib import admin +from .models import Link + + +# Register your models here. + +class LinkAdmin(admin.ModelAdmin): + readonly_fields = ('created', 'updated') + + def get_readonly_fields(self, request, obj=None): + if request.user.groups.filter(name='Personal').exists(): + return ('key', 'name') + else: + return ('created', 'updated') + + +admin.site.register(Link, LinkAdmin) diff --git a/django/social/apps.py b/django/social/apps.py new file mode 100644 index 0000000..77d553d --- /dev/null +++ b/django/social/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class SocialConfig(AppConfig): + name = 'social' + verbose_name = "Redes Sociales" diff --git a/django/social/migrations/__init__.py b/django/social/migrations/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/django/social/migrations/__init__.py diff --git a/django/social/models.py b/django/social/models.py new file mode 100644 index 0000000..c693015 --- /dev/null +++ b/django/social/models.py @@ -0,0 +1,34 @@ +from django.db import models + + +class Link(models.Model): + key = models.SlugField( + verbose_name="Nombre clave", + max_length=100, + unique=True) + + name = models.CharField( + verbose_name="Red social", + max_length=200) + + url = models.URLField( + verbose_name="Enlace", + max_length=200, + null=True, + blank=True) + + created = models.DateTimeField( + auto_now_add=True, + verbose_name='Fecha de creación') + + updated = models.DateTimeField( + auto_now=True, + verbose_name='Fecha de modificación') + + class Meta: + verbose_name = 'enlace' + verbose_name_plural = 'enlaces' + ordering = ["name"] + + def __str__(self): + return self.name diff --git a/django/social/processors.py b/django/social/processors.py new file mode 100644 index 0000000..0c3eb68 --- /dev/null +++ b/django/social/processors.py @@ -0,0 +1,9 @@ +from .models import Link + + +def ctx_dict(request): + ctx = {} + links = Link.objects.all() + for link in links: + ctx[link.key] = link.url + return ctx diff --git a/django/social/tests.py b/django/social/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/django/social/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/django/social/views.py b/django/social/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/django/social/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. |