SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
a4935700
Commit
a4935700
authored
1 year ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
add notes and pins models
related to #164
parent
2bfc0d3d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
scipost_django/pins/admin.py
+24
-1
24 additions, 1 deletion
scipost_django/pins/admin.py
scipost_django/pins/migrations/0001_initial.py
+103
-0
103 additions, 0 deletions
scipost_django/pins/migrations/0001_initial.py
scipost_django/pins/models.py
+60
-1
60 additions, 1 deletion
scipost_django/pins/models.py
with
187 additions
and
2 deletions
scipost_django/pins/admin.py
+
24
−
1
View file @
a4935700
...
...
@@ -3,4 +3,27 @@ __license__ = "AGPL v3"
from
django.contrib
import
admin
# Register your models here.
from
pins.models
import
Note
@admin.register
(
Note
)
class
NoteAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
"
id
"
,
"
regarding__object
"
,
"
title
"
,
"
author
"
,
"
created
"
,
"
modified
"
)
list_filter
=
(
"
created
"
,
"
modified
"
,
"
visibility
"
,
"
regarding_content_type
"
)
search_fields
=
(
"
title
"
,
"
author__username
"
)
date_hierarchy
=
"
created
"
ordering
=
(
"
-created
"
,)
readonly_fields
=
(
"
created
"
,
"
modified
"
,
"
regarding
"
)
fields
=
(
"
title
"
,
"
description
"
,
"
regarding
"
,
"
visibility
"
,
"
author
"
,
"
created
"
,
"
modified
"
,
)
autocomplete_fields
=
(
"
author
"
,)
def
regarding__object
(
self
,
obj
):
return
str
(
obj
.
regarding
)
This diff is collapsed.
Click to expand it.
scipost_django/pins/migrations/0001_initial.py
0 → 100644
+
103
−
0
View file @
a4935700
# Generated by Django 4.2.10 on 2024-03-15 15:53
from
django.conf
import
settings
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
(
"
scipost
"
,
"
0041_alter_remark_contributor_alter_remark_recommendation_and_more
"
,
),
(
"
contenttypes
"
,
"
0002_remove_content_type_name
"
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
"
Note
"
,
fields
=
[
(
"
id
"
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
"
ID
"
,
),
),
(
"
title
"
,
models
.
CharField
(
max_length
=
255
)),
(
"
description
"
,
models
.
TextField
()),
(
"
visibility
"
,
models
.
CharField
(
choices
=
[
(
"
self
"
,
"
Private
"
),
(
"
internal
"
,
"
Internal
"
),
(
"
public
"
,
"
Public
"
),
],
default
=
"
self
"
,
max_length
=
10
,
),
),
(
"
regarding_object_id
"
,
models
.
PositiveIntegerField
(
blank
=
True
,
null
=
True
),
),
(
"
created
"
,
models
.
DateTimeField
(
auto_now_add
=
True
)),
(
"
modified
"
,
models
.
DateTimeField
(
auto_now
=
True
)),
(
"
author
"
,
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
"
scipost.contributor
"
,
),
),
(
"
regarding_content_type
"
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
"
contenttypes.contenttype
"
,
),
),
],
options
=
{
"
ordering
"
:
(
"
-created
"
,),
"
default_related_name
"
:
"
notes
"
,
},
),
migrations
.
CreateModel
(
name
=
"
Pin
"
,
fields
=
[
(
"
id
"
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
"
ID
"
,
),
),
(
"
due_date
"
,
models
.
DateField
(
blank
=
True
,
null
=
True
)),
(
"
created
"
,
models
.
DateTimeField
(
auto_now_add
=
True
)),
(
"
note
"
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
"
pins.note
"
),
),
(
"
user
"
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
settings
.
AUTH_USER_MODEL
,
),
),
],
),
]
This diff is collapsed.
Click to expand it.
scipost_django/pins/models.py
+
60
−
1
View file @
a4935700
...
...
@@ -2,5 +2,64 @@ __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__
=
"
AGPL v3
"
from
django.db
import
models
from
django.contrib.contenttypes.fields
import
GenericForeignKey
# Create your models here.
class
Note
(
models
.
Model
):
"""
A note regarding a (generic) object.
"""
class
Meta
:
ordering
=
(
"
-created
"
,)
default_related_name
=
"
notes
"
VISIBILITY_PRIVATE
=
"
self
"
VISIBILITY_INTERNAL
=
"
internal
"
VISIBILITY_PUBLIC
=
"
public
"
# Notes for everyone
VISIBILITY_CHOICES
=
(
(
VISIBILITY_PRIVATE
,
"
Private
"
),
# For creator only
(
VISIBILITY_INTERNAL
,
"
Internal
"
),
# For group of object managers
(
VISIBILITY_PUBLIC
,
"
Public
"
),
# For everyone
)
title
=
models
.
CharField
(
max_length
=
255
)
description
=
models
.
TextField
()
visibility
=
models
.
CharField
(
max_length
=
10
,
default
=
VISIBILITY_PRIVATE
,
choices
=
VISIBILITY_CHOICES
,
)
regarding_content_type
=
models
.
ForeignKey
(
"
contenttypes.ContentType
"
,
on_delete
=
models
.
CASCADE
,
)
regarding_object_id
=
models
.
PositiveIntegerField
(
blank
=
True
,
null
=
True
)
regarding
=
GenericForeignKey
(
"
regarding_content_type
"
,
"
regarding_object_id
"
)
author
=
models
.
ForeignKey
(
"
scipost.Contributor
"
,
on_delete
=
models
.
CASCADE
,
null
=
True
,
)
created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
modified
=
models
.
DateTimeField
(
auto_now
=
True
)
def
__str__
(
self
):
return
self
.
title
class
Pin
(
models
.
Model
):
"""
A pin associates a note with a user, making it visible in their task list.
"""
note
=
models
.
ForeignKey
(
Note
,
on_delete
=
models
.
CASCADE
)
user
=
models
.
ForeignKey
(
"
auth.User
"
,
on_delete
=
models
.
CASCADE
)
due_date
=
models
.
DateField
(
blank
=
True
,
null
=
True
)
created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
def
__str__
(
self
):
return
f
"
Pin of
{
self
.
note
}
for
{
self
.
user
}
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment