コード例 #1
0
# -*- coding: utf-8 -*-
from django.contrib import admin
from django.conf import settings

from invitation.models import *
from invitation.sample.models import EVENT_MODEL, load_model_from_string

class ContextAdmin(admin.ModelAdmin):
	model = InvitationContext
	list_display = ('inviter', 'related_event')
	def related_event(self, obj):
		return unicode(obj.event.name)


class InvitationAdmin(admin.ModelAdmin):
	model = Invitation
	list_display = ('related_context', 'invitee', 'created', 'accepted')
	def related_context(self, obj):
		return unicode(obj.context.event.name)
	related_context.short_descrption="Set-up"


admin.site.register(InvitationContext, ContextAdmin)
admin.site.register(Invitation, InvitationAdmin)
admin.site.register(Notification)

Event = load_model_from_string(EVENT_MODEL)
admin.site.register(Event)
コード例 #2
0
# coding:utf-8
from datetime import timedelta

from django.test import TestCase
from django.utils import timezone

from invitation.sample.models import EVENT_MODEL, AUTH_USER_MODEL, load_model_from_string
from invitation.models import Invitation, InvitationNotification, InvitationContext, Notification
from invitation.views import find_invitations_to_notify
from invitation.signals import * 

User = load_model_from_string(AUTH_USER_MODEL)
Event = load_model_from_string(EVENT_MODEL)

class InvitationTest(TestCase):
    def createUser(self,username):
        user = User(username=username)
        user.save()
        return user

    def setUp(self):
        self.author = self.createUser(username="******")
        self.inviter = self.createUser(username="******")
        self.invitee = self.createUser(username="******")


        self.notification_day = Notification(name="1 day",
                                     duration=timedelta(days=1))
        self.notification_day.save()

        self.notification_week = Notification(name="7 day",