Ejemplo n.º 1
0
 def moderate(self, status, user = None, notes = ''):
     """
     Why a separate public method?
     To use when you're not sure about the status given
     """
     if status in STATUS_DICT.keys():
         self._moderate(status, user, notes)
Ejemplo n.º 2
0
 def moderate(self, status, user = None, notes = ''):
     """
     Why a separate public method?
     To use when you're not sure about the status given
     """
     if status in STATUS_DICT.keys():
         self._moderate(status, user, notes)
Ejemplo n.º 3
0
 def __init__(self, field, request, params, model, model_admin,
              field_path=None):
     """Extended to set lookup_kwarg & lookup_val."""
     self.lookup_kwarg = 'status'
     # usually, lookup_vals are extracted from request.GET. But we have
     # intentionally removed ``status`` from GET before.  (Have a look at
     # ``django_monitor.admin.MonitorAdmin.queryset`` to know why). So we'll
     # apply regex over the url:
     import re
     status_matches = re.findall(
         r'status=(?P<status>%s)' % '|'.join(STATUS_DICT.keys()),
         request.get_full_path()
     )
     self.lookup_val = status_matches[0] if status_matches else None
     self.lookup_choices = STATUS_DICT.keys()
     super(MonitorFilter, self).__init__(field, request, params, model,
                                         model_admin, field_path)
     self.title = _("Moderation status")
Ejemplo n.º 4
0
 def __init__(
     self, f, request, params, model, model_admin, field_path = None
 ):
     ChoicesFilterSpec.__init__(
         self, f, request, params, model, model_admin, field_path
     )
     self.lookup_kwarg = 'status'
     # usually, lookup_vals are extracted from request.GET. But we have
     # intentionally removed ``status`` from GET before.
     # (Have a look at ``django_monitor.admin.MonitorAdmin.queryset`` to
     # know why). So we'll apply regex over the url:
     import re
     status_matches = re.findall(
         r'status=(?P<status>%s)' % '|'.join(STATUS_DICT.keys()),
         request.get_full_path()
     )
     self.lookup_val = status_matches[0] if status_matches else None
     self.lookup_choices = STATUS_DICT.keys()
Ejemplo n.º 5
0
 def __init__(self,
              field,
              request,
              params,
              model,
              model_admin,
              field_path=None):
     """Extended to set lookup_kwarg & lookup_val."""
     self.lookup_kwarg = 'status'
     # usually, lookup_vals are extracted from request.GET. But we have
     # intentionally removed ``status`` from GET before.  (Have a look at
     # ``django_monitor.admin.MonitorAdmin.queryset`` to know why). So we'll
     # apply regex over the url:
     import re
     status_matches = re.findall(
         r'status=(?P<status>%s)' % '|'.join(STATUS_DICT.keys()),
         request.get_full_path())
     self.lookup_val = status_matches[0] if status_matches else None
     self.lookup_choices = STATUS_DICT.keys()
     super(MonitorFilter, self).__init__(field, request, params, model,
                                         model_admin, field_path)
     self.title = _("Moderation status")
Ejemplo n.º 6
0
from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
import datetime

from django_monitor.conf import (
    STATUS_DICT, PENDING_STATUS, APPROVED_STATUS, CHALLENGED_STATUS
)
STATUS_CHOICES = STATUS_DICT.items()

class MonitorEntryManager(models.Manager):
    """ Custom Manager for MonitorEntry"""

    def get_for_instance(self, obj):
        ct = ContentType.objects.get_for_model(obj.__class__)
        try:
            mo = MonitorEntry.objects.get(content_type = ct, object_id = obj.pk)
            return mo
        except MonitorEntry.DoesNotExist:
            pass

class MonitorEntry(models.Model):
    """ Each Entry will monitor the status of one moderated model object"""
    objects = MonitorEntryManager()
    
    timestamp = models.DateTimeField(
        auto_now_add = True, blank = True, null = True
    )
    status = models.CharField(max_length = 2, choices = STATUS_CHOICES)
    status_by = models.ForeignKey(User, blank = True, null = True)
Ejemplo n.º 7
0
from django.db import models
from django.contrib.contenttypes.fields import GenericForeignKey
import datetime

from . import model_from_queue
from django_monitor.conf import (
    STATUS_DICT, PENDING_STATUS, APPROVED_STATUS, CHALLENGED_STATUS
)
STATUS_CHOICES = STATUS_DICT.items()


class MonitorEntryManager(models.Manager):
    """ Custom Manager for MonitorEntry"""

    def get_for_instance(self, obj):
        from django.contrib.contenttypes.models import ContentType
        ct = ContentType.objects.get_for_model(obj.__class__)
        try:
            mo = MonitorEntry.objects.get(content_type = ct, object_id = obj.pk)
            return mo
        except MonitorEntry.DoesNotExist:
            pass


class MonitorEntry(models.Model):
    """ Each Entry will monitor the status of one moderated model object"""
    objects = MonitorEntryManager()

    timestamp = models.DateTimeField(
        auto_now_add = True, blank = True, null = True
    )