Commit e474c966 authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier

fix: missing webid without djangoldp_account

parent 8106cfb6
Pipeline #6097 passed with stage
in 1 minute and 23 seconds
import validators
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import models
from django.db.models.base import ModelBase
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.urls import get_resolver
from django.urls import reverse_lazy, get_resolver
from django.utils.datastructures import MultiValueDictKeyError
from django.utils.decorators import classonlymethod
......@@ -180,3 +182,16 @@ def auto_urlid(sender, instance, **kwargs):
if (instance.urlid is None or instance.urlid == '' or 'None' in instance.urlid):
instance.urlid = instance.get_absolute_url()
instance.save()
if 'djangoldp_account' not in settings.DJANGOLDP_PACKAGES:
def webid(self):
# hack : We user webid as username for external user (since it's an uniq identifier too)
if validators.url(self.username):
webid = self.username
else:
webid = '{0}{1}'.format(settings.BASE_URL, reverse_lazy('user-detail', kwargs={'pk': self.pk}))
return webid
get_user_model()._meta.serializer_fields = ['@id']
get_user_model().webid = webid
......@@ -8,7 +8,6 @@ urlpatterns = [
url(r'^messages/', LDPViewSet.urls(model=Message, permission_classes=[], fields=["@id", "text", "conversation"], nested_fields=['conversation'])),
url(r'^conversations/', LDPViewSet.urls(model=Conversation, nested_fields=["message_set"], permission_classes=())),
url(r'^tasks/', LDPViewSet.urls(model=Task, permission_classes=())),
url(r'^users/', LDPViewSet.urls(model=settings.AUTH_USER_MODEL, permission_classes=[])),
url(r'^dummys/', LDPViewSet.urls(model=Dummy, permission_classes=[], lookup_field='slug',)),
]
import validators
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import models
from django.urls import reverse_lazy
from django.utils.datetime_safe import date
from djangoldp.models import Model
......@@ -171,17 +169,6 @@ class Circle(Model):
rdf_type = 'hd:circle'
depth = 1
def webid(self):
# hack : We user webid as username for external user (since it's an uniq identifier too)
if validators.url(self.username):
webid = self.username
else:
webid = '{0}{1}'.format(settings.BASE_URL, reverse_lazy('user-detail', kwargs={'pk': self.pk}))
return webid
get_user_model()._meta.serializer_fields = ['@id', 'username', 'first_name', 'last_name', 'email', 'userprofile',
'conversation_set', 'circle_set']
get_user_model().webid = webid
get_user_model()._meta.anonymous_perms = ['view', 'add']
......@@ -6,6 +6,7 @@ from django.conf.urls import url, include
from djangoldp.models import LDPSource, Model
from djangoldp.permissions import LDPPermissions
from djangoldp.views import LDPSourceViewSet, WebFingerView
from djangoldp.views import LDPViewSet
def __clean_path(path):
......@@ -46,3 +47,6 @@ for package in settings.DJANGOLDP_PACKAGES:
urlpatterns.append(url(r'^', include('{}.djangoldp_urls'.format(package))))
except ModuleNotFoundError:
pass
if 'djangoldp_account' not in settings.DJANGOLDP_PACKAGES:
urlpatterns.append(url(r'^users/', LDPViewSet.urls(model=settings.AUTH_USER_MODEL, permission_classes=[])))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment