Esempio n. 1
0
        notification = Notification(notification_type=notification_type)
        notification.save()
        notification.users.add(self.owner)
        notification.add_dictionary({"chapter": self.chapter.slug, "processor": self.processed_by.get_profile().display_name, "request_title": self.title, "request_pk": self.pk})
        notification.save()
        notification.dispatch()

    def deny(self, user):
        self.response = Leadership.DENIED
        self.processed_by = user
        self.save()


def create_leadership(sender, instance, created, **kwargs):
    if created:
        notification_type = NotificationType.objects.get(name="new_leadership")
        notification = Notification(notification_type=notification_type)
        notification.save()
        from petri.account.models import UserProfile
        for leader_profile in UserProfile.objects.filter(chapter=instance.chapter, is_leader=True):
            if "?n=" + leader_profile.user.username.lower() not in instance.content:
                notification.users.add(leader_profile.user)
        notification.add_dictionary({"chapter": instance.chapter.slug, "bulletin": instance.pk, "title": instance.title, "content": instance.content})
        notification.save()
        notification.dispatch()


connect_bulletin_signals(Leadership)
post_save.connect(create_leadership, sender=Leadership)
Esempio n. 2
0
from django.conf import settings

from django.db import models

from petri.bulletin.models import Bulletin
from petri.bulletin.models import connect_bulletin_signals


class Introduction(Bulletin):
    pass


connect_bulletin_signals(Introduction)
Esempio n. 3
0
from django.conf import settings

from django.db import models
from django.contrib.auth.models import User

from petri.bulletin.models import Bulletin
from petri.bulletin.models import connect_bulletin_signals


class Event(Bulletin):
    start = models.DateTimeField()
    end = models.DateTimeField(null=True, default=None)
    where = models.CharField(max_length=settings.WHERE_MAX_LEN)


connect_bulletin_signals(Event)
Esempio n. 4
0
from django.db import models
from django.contrib.auth.models import User

from petri.bulletin.models import Bulletin
from petri.bulletin.models import connect_bulletin_signals


class Pending(Bulletin):
    pass

connect_bulletin_signals(Pending)
Esempio n. 5
0
          ini, tag_created = Initiative.objects.get_or_create(project=instance, defaults={ "name": name })
          
          if not tag_created:
              ini.name = name
              ini.save()

    def override_template(self):
        return "project/project.jade"

    def related_talk(self):
        return self.initiative.bulletins_by_type(Talk)

    def related_events(self):
        return self.initiative.bulletins_by_type(Event)

    def follow(self, user):
        super(Project, self).follow(user)

        profile = user.get_profile()
        profile.initiatives.add(self.initiative)

    def unfollow(self, user):
        super(Project, self).unfollow(user)

        profile = user.get_profile()
        profile.initiatives.remove(self.initiative)


connect_bulletin_signals(Project)
post_save.connect(Project.attach_tag, sender=Project)
Esempio n. 6
0
class TalkFeed(Feed):

    def get_object(self, request, chapter_slug):
        return get_object_or_404(Chapter, slug=chapter_slug)

    def title(self, obj):
        return "Hacker Union %s" % obj.location

    def link(self, obj):
        return "/%s/" % obj.slug

    def description(self, obj):
        return "Recent Updates in Hacker Union %s" % obj.location

    def items(self, obj):
        return Bulletin.objects.filter(chapter=obj, is_official=False).order_by('-created')[:10]

    def item_title(self, item):
        return item.content[:100] + "..." if len(item.content) > 100 else item.content

    def item_description(self, item):
        return item.content

    # item_link is only needed if NewsItem has no get_absolute_url method.
    def item_link(self, item):
        return "/" + item.chapter.slug + "/" + str(item.pk)


connect_bulletin_signals(Talk)