コード例 #1
100
ファイル: views.py プロジェクト: FullstackStation/Booktype
def add_appearance_for_user(message, word, sent, direct=False, orig_word=None):
    timeline = get_endpoint_or_none(word)
    if timeline and timeline not in sent:
        appearance = PostAppearance(
            post=message, timestamp=message.timestamp, 
            endpoint=timeline)
        appearance.save()
        sent[timeline] = True

        if timeline.wants_notification(message, orig_word):
            # XXX wanted has to be first to be sent to take effect
            # XXX check that email addr is verified before sending

            user = timeline.as_user()
            SERVER_ROOT = "/".join(settings.BOOKI_URL.split("/")[:3])
            body = render_to_string('messaging/new_message_email.txt', 
                                    dict(user=user, post=message,
                                         SERVER_ROOT=SERVER_ROOT,
                                         DATA_URL=settings.DATA_URL))
            if orig_word == word or not orig_word:
                reason = message.sender
            else:
                reason = orig_word
            send_mail(_('Message from %s') % reason, 
                      body,
                      settings.EMAIL_HOST_USER,
                      [user.email], fail_silently=True)
コード例 #2
0
def add_appearance_for_user(message, word, sent, direct=False, orig_word=None):
    timeline = get_endpoint_or_none(word)
    if timeline and timeline not in sent:
        appearance = PostAppearance(post=message,
                                    timestamp=message.timestamp,
                                    endpoint=timeline)
        appearance.save()
        sent[timeline] = True

        if timeline.wants_notification(message, orig_word):
            # XXX wanted has to be first to be sent to take effect
            # XXX check that email addr is verified before sending

            user = timeline.as_user()
            SERVER_ROOT = "/".join(settings.BOOKI_URL.split("/")[:3])
            body = render_to_string(
                'messaging/new_message_email.txt',
                dict(user=user,
                     post=message,
                     SERVER_ROOT=SERVER_ROOT,
                     DATA_URL=settings.DATA_URL))
            if orig_word == word or not orig_word:
                reason = message.sender
            else:
                reason = orig_word
            send_mail(_('Message from %s') % reason,
                      body,
                      settings.EMAIL_HOST_USER, [user.email],
                      fail_silently=True)
コード例 #3
0
def add_appearance_for_tag(message, word, sent, direct=False, orig_word=None):
    timeline = get_endpoint_or_none(syntax=word)
    if timeline and timeline not in sent:
        appearance = PostAppearance(post=message,
                                    timestamp=message.timestamp,
                                    endpoint=timeline)
        appearance.save()
        sent[timeline] = True

        # followers of the tag
        add_appearance_for_followers(message, word, sent, False, orig_word)
コード例 #4
0
ファイル: views.py プロジェクト: FullstackStation/Booktype
def add_appearance_for_tag(message, word, sent, direct=False, orig_word=None):
    timeline = get_endpoint_or_none(syntax=word)
    if timeline and timeline not in sent:
        appearance = PostAppearance(
            post=message, timestamp=message.timestamp, 
            endpoint=timeline)
        appearance.save()
        sent[timeline] = True

        # followers of the tag
        add_appearance_for_followers(message, word, sent, False, orig_word)
コード例 #5
0
ファイル: views.py プロジェクト: FullstackStation/Booktype
def add_appearance_for_group(message, word, sent, direct=False, orig_word=None):
    timeline = get_endpoint_or_none(word)
    if timeline and timeline not in sent:
        appearance = PostAppearance(
            post=message, timestamp=message.timestamp, 
            endpoint=timeline)
        appearance.save()
        sent[timeline] = True

        # members "follow" their groups
        group = get_or_none(BookiGroup.objects, url_name=word[1:])
        for user in group.members.all():
            add_appearance_for_user(message, "@"+user.username, sent, direct, orig_word)
コード例 #6
0
ファイル: views.py プロジェクト: zeuser/Booktype
def add_appearance_for_group(message, word, sent, direct=False, orig_word=None):
    timeline = get_endpoint_or_none(word)
    if timeline and timeline not in sent:
        appearance = PostAppearance(
            post=message, timestamp=message.timestamp,
            endpoint=timeline)
        appearance.save()
        sent[timeline] = True

        # members "follow" their groups
        group = get_or_none(BookiGroup.objects, url_name=word[1:])
        for user in group.members.all():
            add_appearance_for_user(message, "@"+user.username, sent, direct, orig_word)
コード例 #7
0
ファイル: views.py プロジェクト: FullstackStation/Booktype
def add_appearance_for_book(message, word, sent, direct=False, orig_word=None):
    timeline = get_endpoint_or_none(word)
    if timeline and timeline not in sent:
        appearance = PostAppearance(
            post=message, timestamp=message.timestamp, 
            endpoint=timeline)
        appearance.save()
        sent[timeline] = True

        # followers of the book tag
        add_appearance_for_followers(message, word, sent, False, orig_word)

        # group "follows" its books
        book = get_or_none(Book.objects, url_title=word[1:])
        if book and book.group:
            add_appearance_for_group(message, "!"+book.group.url_name, sent, direct, orig_word)
コード例 #8
0
ファイル: views.py プロジェクト: zeuser/Booktype
def add_appearance_for_book(message, word, sent, direct=False, orig_word=None):
    timeline = get_endpoint_or_none(word)
    if timeline and timeline not in sent:
        appearance = PostAppearance(
            post=message, timestamp=message.timestamp,
            endpoint=timeline)
        appearance.save()
        sent[timeline] = True

        # followers of the book tag
        add_appearance_for_followers(message, word, sent, False, orig_word)

        # group "follows" its books
        book = get_or_none(Book.objects, url_title=word[1:])
        if book and book.group:
            add_appearance_for_group(message, "!"+book.group.url_name, sent, direct, orig_word)