Ejemplo n.º 1
0
    def fromJson(json_obj):

        ModelValidator.json('event', json_obj)

        event = Event(
            name=json_obj["name"],
            datetime=parser.parse(json_obj["datetime"]),
            venue_id=json_obj["venue_id"],
            creator_id=json_obj["creator_id"],
        )

        #create invitations
        for p in json_obj['participant_ids']:
            user = User.query.get(p)
            if user is not None:
                i = Invitation()
                i.user = user
                event.participant_ids.append(i)

        if 'public' in json_obj:
            event.public = json_obj["public"]

        if 'tags' in json_obj:
            for t in json_obj['tags']:
                tag = Tag.get_or_create(name=t)
                event.tags.append(tag)

        return event
Ejemplo n.º 2
0
def invite_other(invitor, invitee_mail):
    from invitation import Invitation
    from mails import send_invite

    invitee_mail = invitee_mail.lower()
    if not Invitation.is_exist({'email': invitee_mail}):
        gcnt = global_info['invitations_count']
        if gcnt >= af_conf['invitation_limit']:
            return 4  #invitation not available, full
        if invitor.invitations <= 0:
            return 1  #your pool is empty
        invi = Invitation(attrs={'email': invitee_mail})
        invi.date = datetime.now()
        invi.invitor = invitor.email
        global_info.inc('invitations_count')
        invitor.invitations -= 1
    if send_invite(invitor, invitee_mail):
        return 0  #successfull
    return 2  #mail sending error
 def invitations(self):
     gci = self.invitationQuery.get_current_invitiations_for_site
     retval = [Invitation(self.context, i['invitation_id'])
                 for i in gci(self.siteInfo.id, self.userInfo.id)]
     return retval
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-
from invitation import db, Invitation

if __name__ == '__main__':
    db.drop_all()
    db.create_all()
    inv = Invitation(
        'janeandjohn', 'Jane & John',
        'You all know us. And we all know you. We are getting married.')
    db.session.add(inv)
    db.session.commit()
Ejemplo n.º 5
0
from audience import Audience
from bag import Bag
from invitation import Invitation
from ticket import Ticket
from ticketseller import TicketSeller
from ticketbox import TicketBox

if __name__ == "__main__":
    TICKET_PRICE = 5000

    invitation = Invitation()

    bag_with_invitation = Bag(invitation=invitation)
    bag_with_money = Bag(money=TICKET_PRICE)
    
    hit_audience = Audience(bag=bag_with_invitation)
    non_hit_audience = Audience(bag=bag_with_money)

    ticket1 = Ticket(price=TICKET_PRICE)
    ticket2 = Ticket(price=TICKET_PRICE)

    ticketbox = TicketBox(tickets=[ticket1, ticket2], money=0)
    ticketsellor = TicketSeller(ticketbox=ticketbox)

    ticketsellor.sell_ticket_to_audience(audience=hit_audience)
    ticketsellor.sell_ticket_to_audience(audience=non_hit_audience)