2012-08-15 4 views
0

내가 함께 django-notificationdjango-messages 프로젝트를 사용하고 장고 메시지에 대한 메시지가 수신되는 경우에 대한 기본 통지 유형을 내장 장고 - 알림 통합을 활용하고, 나는, 그러나,로 등syncdb 동안 django-messages가 알림 유형을 만드는 방법은 무엇입니까?

대답 이러한 기본 NoticeType 오브젝트가 작성되는 f}을 판별 할 수 없습니다. django-notification 문서에서는 management.py 파일에서 post_syncdb 신호를 사용하는 것을 제안합니다. 이는 내 자신의 맞춤 알림을 위해 수행하고있는 작업입니다. 나는 이러한 통지 유형이 정의 된 코드의 어느 부분에서도 찾을 수 없습니다. 그러나 새로운 데이터베이스에서 syncdb를 실행할 때마다 마술처럼 나타납니다. 다음과 같이

장고 - 메시지 응용 프로그램에 의해 생성되는 통지 유형의 "레이블"속성은 다음과 같습니다

  • 이 messages_sent
  • 이 messages_deleted messages_reply_received messages_replied
  • messages_received
  • messages_recovered

답변

0

django_messages/management.py :

from django.db.models import get_models, signals 
from django.conf import settings 
from django.utils.translation import ugettext_noop as _ 

if "notification" in settings.INSTALLED_APPS: 
    from notification import models as notification 

    def create_notice_types(app, created_models, verbosity, **kwargs): 
     notification.create_notice_type("messages_received", _("Message Received"), _("you have received a message"), default=2) 
     notification.create_notice_type("messages_sent", _("Message Sent"), _("you have sent a message"), default=1) 
     notification.create_notice_type("messages_replied", _("Message Replied"), _("you have replied to a message"), default=1) 
     notification.create_notice_type("messages_reply_received", _("Reply Received"), _("you have received a reply to a message"), default=2) 
     notification.create_notice_type("messages_deleted", _("Message Deleted"), _("you have deleted a message"), default=1) 
     notification.create_notice_type("messages_recovered", _("Message Recovered"), _("you have undeleted a message"), default=1) 

    signals.post_syncdb.connect(create_notice_types, sender=notification) 
else: 
    print "Skipping creation of NoticeTypes as notification app not found" 

https://github.com/arneb/django-messages/blob/master/django_messages/management.py

종류는 여기에서 정의하고 post_syncdb 신호에 걸려있다.

+0

글쎄, 지금 바보 같아. 나는 Eclipse/PyDev에서 .pyc 파일을 숨기고 이것을 보았다. 어떤 이유로 management.py는 없지만 management.pyc는 있습니다. 그게 정확히 내가 찾던 것이지, 단지 열심히 만만치 않다 ... :-( – gravelpot

+3

오늘은 늦었 어. 맥주를 마실 시간이야! –