Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
Revue de Press
Commits
8f6731e3
Commit
8f6731e3
authored
Apr 22, 2017
by
luxcem
Browse files
migrations and admin for articles / votes
parent
60d8e115
Changes
4
Hide whitespace changes
Inline
Side-by-side
apps/rp/admin.py
View file @
8f6731e3
from
django.contrib
import
admin
# Register your models here.
from
.models
import
Article
,
UnDVotes
admin
.
site
.
register
(
Article
)
admin
.
site
.
register
(
UnDVotes
)
apps/rp/migrations/0003_auto_20170422_1432.py
0 → 100644
View file @
8f6731e3
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-04-22 14:32
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'rp'
,
'0002_undvotes'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'article'
,
options
=
{
'verbose_name'
:
'Article'
,
'verbose_name_plural'
:
'Articles'
},
),
migrations
.
AlterModelOptions
(
name
=
'undvotes'
,
options
=
{
'verbose_name'
:
'Vote'
,
'verbose_name_plural'
:
'Votes'
},
),
migrations
.
AddField
(
model_name
=
'article'
,
name
=
'und_score'
,
field
=
models
.
IntegerField
(
default
=
0
),
),
]
apps/rp/models/article.py
View file @
8f6731e3
...
...
@@ -18,3 +18,7 @@ class Article(UnDVotedMixin):
published
=
models
.
BooleanField
(
_
(
"Published"
))
tags
=
TaggableManager
()
class
Meta
:
verbose_name
=
_
(
"Article"
)
verbose_name_plural
=
_
(
"Articles"
)
apps/rp/models/vote.py
View file @
8f6731e3
...
...
@@ -4,6 +4,7 @@ from django.contrib.contenttypes.fields import GenericForeignKey
from
django.contrib.contenttypes.fields
import
GenericRelation
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.auth.models
import
User
from
django.utils.translation
import
ugettext_lazy
as
_
class
UnDVotes
(
models
.
Model
):
...
...
@@ -23,6 +24,10 @@ class UnDVotes(models.Model):
#: The Voted object
content_object
=
GenericForeignKey
(
"content_type"
,
"object_id"
)
class
Meta
:
verbose_name
=
_
(
"Vote"
)
verbose_name_plural
=
_
(
"Votes"
)
def
__str__
(
self
):
return
"{}:{}:{}"
.
format
(
self
.
user
,
self
.
content_object
,
self
.
score
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment