Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Django LDP
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
20
Issues
20
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Startin blox
djangoldp-packages
Django LDP
Commits
e474c966
Verified
Commit
e474c966
authored
Oct 21, 2019
by
Jean-Baptiste Pasquier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: missing webid without djangoldp_account
parent
8106cfb6
Pipeline
#6097
passed with stage
in 1 minute and 23 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
15 deletions
+20
-15
djangoldp/models.py
djangoldp/models.py
+16
-1
djangoldp/tests/djangoldp_urls.py
djangoldp/tests/djangoldp_urls.py
+0
-1
djangoldp/tests/models.py
djangoldp/tests/models.py
+0
-13
djangoldp/urls.py
djangoldp/urls.py
+4
-0
No files found.
djangoldp/models.py
View file @
e474c966
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
djangoldp/tests/djangoldp_urls.py
View file @
e474c966
...
...
@@ -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'
,)),
]
djangoldp/tests/models.py
View file @
e474c966
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'
]
djangoldp/urls.py
View file @
e474c966
...
...
@@ -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
=
[])))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment