Commit 60d8e115 authored by luxcem's avatar luxcem
Browse files

moves rp models and adds votes migrations

parent ec33d53e
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-04-22 14:18
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('rp', '0001_initial'),
operations = [
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('score', models.IntegerField(default=True)),
('object_id', models.PositiveIntegerField()),
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
from .vote import UnDVotes, UnDVotedMixin # noqa
from .article import Article # noqa
from django.db import models
from django.utils.translation import ugettext_lazy as _
from taggit.managers import TaggableManager
from .vote import UnDVotedMixin
class Article(models.Model):
class Article(UnDVotedMixin):
url = models.URLField("URL")
lang = models.CharField(_("Language"), max_length=50)
metadata = models.TextField(_("Opengraph metadata"))
......@@ -36,6 +36,9 @@ class UnDVotedMixin(models.Model):
#: Score of the model
und_score = models.IntegerField(default=0)
class Meta:
abstract = True
def upvote(self, user):
diff_score = 0
......@@ -86,6 +89,3 @@ class UnDVotedMixin(models.Model):
score = self.und_votes.aggregate(Sum("score"))["score__sum"] or 0
# Update self score, use update and filter to avoid triggering signals
class Meta:
abstract = True
Supports Markdown
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