Skip to content

Commit

Permalink
added notification model and updated voting views
Browse files Browse the repository at this point in the history
  • Loading branch information
casuru committed Oct 25, 2017
1 parent 0a38ca5 commit 02e2193
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 2 deletions.
Empty file added notify/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions notify/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions notify/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class NotifyConfig(AppConfig):
name = 'notify'
33 changes: 33 additions & 0 deletions notify/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from __future__ import unicode_literals

from django.db import models
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType

# Create your models here.

class Action(models.Model):

UP_VOTE = 'u'
DOWN_VOTE = 'd'
REPORT = 'r'

ACTIONS = (
(UP_VOTE, 'Up Vote'),
(DOWN_VOTE, 'Down Vote'),
(REPORT, 'Report')
)

user = models.ForeignKey('authentication.Account')
action = models.CharField(max_length = 1, choices = ACTIONS)
date_added = models.DateTimeField(auto_now_add = True)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')


def __unicode__(self):


return self.action

3 changes: 3 additions & 0 deletions notify/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions notify/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
5 changes: 3 additions & 2 deletions spotholes/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""
from django.conf.urls import url, include
from django.contrib import admin
from potholes.views import ListPotholeView, PotholeDetailView, PotholeVoteView, PotholeByUserListView, PotholeReportView, PotholeReportDetailView
from potholes.views import ListPotholeView, PotholeDetailView, PotholeDownVoteView, PotholeUpVoteView, PotholeByUserListView, PotholeReportView, PotholeReportDetailView
from authentication.views import AccountListView, AccountDetailView, AccountStatusView, SignInView, PasswordResetRequestView, PasswordResetConfirmView

urlpatterns = [
Expand All @@ -30,7 +30,8 @@
url(r'^api/v1/accounts/(?P<username>\w+)/potholes/$', PotholeByUserListView.as_view(), name = 'pothole-account-list'),
url(r'^api/v1/potholes/$', ListPotholeView.as_view(), name = 'pothole-list'),
url(r'^api/v1/potholes/(?P<pk>[0-9]+)/$', PotholeDetailView.as_view(), name = 'pothole-detail'),
url(r'^api/v1/potholes/(?P<pk>[0-9]+)/votes/$', PotholeVoteView.as_view(), name = 'vote-list'),
url(r'^api/v1/potholes/(?P<pk>[0-9]+)/up_vote/$', PotholeUpVoteView.as_view(), name = 'up_votes'),
url(r'^api/v1/potholes/(?P<pk>[0-9]+)/down_vote/$', PotholeDownVoteView.as_view(), name = 'up_votes'),
url(r'^api/v1/potholes/(?P<pk>[0-9]+)/reports/$', PotholeReportView.as_view(), name = 'report-list'),
url(r'^api/v1/potholes/(?P<p_pk>[0-9]+)/reports/(?P<r_pk>[0-9]+)/$', PotholeReportDetailView.as_view(), name = 'report-detail')

Expand Down

0 comments on commit 02e2193

Please sign in to comment.