Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kszkepzes-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
KSZK
DevTeam
kszkepzes
old
kszkepzes-backend
Commits
3f44656d
Commit
3f44656d
authored
7 years ago
by
Barnabás Czémán
Browse files
Options
Downloads
Patches
Plain Diff
Add user notes
parent
f0ecc985
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/stats/admin.py
+7
-0
7 additions, 0 deletions
src/stats/admin.py
src/stats/migrations/0008_note.py
+27
-0
27 additions, 0 deletions
src/stats/migrations/0008_note.py
src/stats/models.py
+13
-0
13 additions, 0 deletions
src/stats/models.py
src/stats/resources.py
+22
-0
22 additions, 0 deletions
src/stats/resources.py
with
69 additions
and
0 deletions
src/stats/admin.py
+
7
−
0
View file @
3f44656d
...
...
@@ -9,3 +9,10 @@ from . import resources
class
EventAdmin
(
ExportMixin
,
admin
.
ModelAdmin
):
filter_horizontal
=
(
'
visitors
'
,
)
resource_class
=
resources
.
EventResource
@admin.register
(
models
.
Note
)
class
NoteAdmin
(
ExportMixin
,
admin
.
ModelAdmin
):
list_display
=
(
'
user
'
,
'
note
'
,
'
event
'
,
'
created_by
'
,
'
created_at
'
,
'
updated_at
'
)
list_filter
=
(
'
user
'
,
'
created_by
'
,
'
event
'
)
resource_class
=
resources
.
NoteResource
This diff is collapsed.
Click to expand it.
src/stats/migrations/0008_note.py
0 → 100644
+
27
−
0
View file @
3f44656d
# Generated by Django 2.0.1 on 2018-02-21 00:18
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
account
'
,
'
0017_auto_20180205_2004
'
),
(
'
stats
'
,
'
0007_auto_20180215_0018
'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'
Note
'
,
fields
=
[
(
'
id
'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'
ID
'
)),
(
'
note
'
,
models
.
TextField
()),
(
'
created_at
'
,
models
.
DateTimeField
(
auto_now_add
=
True
)),
(
'
updated_at
'
,
models
.
DateTimeField
(
auto_now
=
True
)),
(
'
created_by
'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
created_notes
'
,
to
=
'
account.Profile
'
)),
(
'
event
'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
notes
'
,
to
=
'
stats.Event
'
)),
(
'
user
'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'
notes
'
,
to
=
'
account.Profile
'
)),
],
),
]
This diff is collapsed.
Click to expand it.
src/stats/models.py
+
13
−
0
View file @
3f44656d
...
...
@@ -15,3 +15,16 @@ class Event(models.Model):
def
__str__
(
self
):
return
self
.
name
class
Note
(
models
.
Model
):
event
=
models
.
ForeignKey
(
Event
,
related_name
=
'
notes
'
,
on_delete
=
models
.
CASCADE
)
user
=
models
.
ForeignKey
(
Profile
,
related_name
=
'
notes
'
,
on_delete
=
models
.
CASCADE
)
note
=
models
.
TextField
()
created_by
=
models
.
ForeignKey
(
Profile
,
related_name
=
'
created_notes
'
,
on_delete
=
models
.
CASCADE
)
created_at
=
models
.
DateTimeField
(
auto_now_add
=
True
,
editable
=
False
)
updated_at
=
models
.
DateTimeField
(
auto_now
=
True
,
editable
=
False
)
def
__str__
(
self
):
return
self
.
note
This diff is collapsed.
Click to expand it.
src/stats/resources.py
+
22
−
0
View file @
3f44656d
...
...
@@ -17,3 +17,25 @@ class EventResource(resources.ModelResource):
'
date
'
,
'
visitors
'
,
)
class
NoteResource
(
resources
.
ModelResource
):
created_by
=
fields
.
Field
()
user
=
fields
.
Field
()
class
Meta
:
model
=
models
.
Note
fields
=
(
'
user
'
,
'
event__name
'
,
'
note
'
,
'
created_at
'
,
'
updated_at
'
,
'
created_by
'
,
)
def
dehydrate_created_by
(
self
,
obj
):
return
obj
.
created_by
.
full_name
def
dehydrate_user
(
self
,
obj
):
return
obj
.
user
.
full_name
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