Example #1
0
#     """
#     column_names = "votable state priority rating nickname *"
#     order_by = ['-id']
    



def welcome_messages(ar):
    """Yield a message "Your favourites are X, Y, ..." for the welcome
page.

    This message mentions all voted objects of the requesting user
    and whose :attr:`nickname <Vote.nickname>` is not empty.

    """
    Vote = rt.models.votes.Vote
    qs = Vote.objects.filter(user=ar.get_user()).exclude(nickname='')
    qs = qs.order_by('priority')
    if qs.count() > 0:
        chunks = [six.text_type(_("Your favourite {0} are ").format(
            config.votable_model._meta.verbose_name_plural))]
        chunks += join_elems([
            ar.obj2html(obj.votable, obj.nickname)
            for obj in qs])
        chunks.append('.')
        yield E.span(*chunks)

dd.add_welcome_handler(welcome_messages)

Example #2
0
    and whose :attr:`nickname <Star.nickname>` is not empty.

    """
    Star = rt.modules.stars.Star
    qs = Star.objects.filter(user=ar.get_user()).exclude(nickname='')
    if qs.count() > 0:
        chunks = [unicode(_("Your stars are "))]
        chunks += join_elems([
            ar.obj2html(obj.owner, obj.nickname or unicode(obj.owner))
            for obj in qs
        ])
        chunks.append('.')
        yield E.span(*chunks)


dd.add_welcome_handler(welcome_messages)

from lino.modlib.changes.models import Change
from django.db.models.signals import post_save


@dd.receiver(post_save, sender=Change)
def notify_handler(sender, instance=None, **kwargs):
    self = instance  # a Change object
    notify = rt.modules.notifier.Notification.notify
    others = rt.modules.stars.Star.for_obj(self.master).exclude(user=self.user)
    ar = BaseRequest(user=self.user)
    for star in others:
        msg = "{obj} was modified by %s" % self.user
        notify(ar, self.master, star.user, msg)
Example #3
0
            if evt.project is None:
                txt = _("{label} #{id}").format(**ctx)
            else:
                ctx.update(project=unicode(evt.project))
                txt = _("{label} with {project}").format(**ctx)
            chunks.append(ar.obj2html(evt, txt))
            chunks += [
                ' (',
                ar.instance_action_button(evt.close_meeting),
                ')']
            sep = ', '
        chunks.append('. ')
        yield E.span(*chunks)
            

dd.add_welcome_handler(you_are_busy_messages)


class EventType(EventType):
    """
    .. attribute:: invite_client
    .. attribute:: esf_field

    """

    #~ invite_team_members = models.BooleanField(
        #~ _("Invite team members"),default=False)
    # invite_team_members = dd.ForeignKey('users.Team', blank=True, null=True)
    invite_client = models.BooleanField(_("Invite client"), default=False)
    esf_field = dd.DummyField()