コード例 #1
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_add_unexisting_venue_to_eventpart(self):
     # Setup
     em = logic.EventManager()
     vm = logic.VenueManager()
     # Validate
     self.assertRaises(ex.VenueNotFoundError, em.add_venue_to_eventpart,
                       self.eventpart.id, 999)
コード例 #2
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_check_if_eventpart_exists(self):
     # Setup
     em = logic.EventManager()
     event = em.start_event(self.account.id, "name")
     eventpart = em.add_eventpart(event.id)
     # Validate
     self.assertTrue(em.eventpart_exists(eventpart.id))
コード例 #3
0
def update_event(client_id, event_id, values_dict):
    """
    Entrypoint for updating event information.
    
    Args:
        event_id:
            Id of the event to update
        values_dict:
            Dictionary containing information that requires updating. The 
            dictionary can contain the following information:
                -  active: Boolean for turning the event active or inactive.
    
    Returns:
        A dictionary containing a key "updated" which is True if the update
        was completed successfully and False if not. 
        
        {'updated': True}
        
        Even if nothing was updated, it will return True as a value to 
        indicate there were no problems encountered.
    """
    em = logic.EventManager()
    # check if activation is required
    try:
        require_event_owner(client_id, event_id)
        if values_dict.get('active'):
            # also activate all ticket_types connected to it.
            event = em.lookup_event_by_id(event_id)
            event.publish()
    except ex.TickeeError, e:
        transaction.abort()
        return marshalling.error(e)
コード例 #4
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_start_event(self):
     # Setup
     em = logic.EventManager()
     # Test
     event = em.start_event(self.account.id, "Event Name")
     # Validate
     self.assertEqual(event.name, "Event Name", "Event has wrong name.")
コード例 #5
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_add_venue_to_unexisting_eventpart(self):
     # Setup
     em = logic.EventManager()
     vm = logic.VenueManager()
     venue = vm.create_venue("Marktplein Lokeren")
     # Validate
     self.assertRaises(ex.EventPartNotFoundError, em.add_venue_to_eventpart,
                       999, venue.id)
コード例 #6
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_add_eventpart_with_unexisting_venue(self):
     # Setup
     em = logic.EventManager()
     # Validate
     self.assertRaises(ex.VenueNotFoundError,
                       em.add_eventpart,
                       self.event.id,
                       venue_id=999)
コード例 #7
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_add_eventpart(self):
     # Setup
     em = logic.EventManager()
     # Test
     eventpart = em.add_eventpart(self.event.id)
     # Validate
     self.assertEqual(eventpart.event_id, self.event.id,
                      "The eventpart is not connected to the event")
コード例 #8
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_lookup_event_by_id(self):
     # Setup
     em = logic.EventManager()
     event = em.start_event(self.account.id, "name")
     # Test
     event_found = em.lookup_event_by_id(event.id)
     # Validate
     self.assertEqual(event, event_found, "Event did not match")
コード例 #9
0
def create_event(oauth_client_id,
                 event_name,
                 venue_id=None,
                 price=None,
                 units=None,
                 currency="EUR",
                 account_id=None):
    """
    Entrypoint for creating an event and returning its information back as a
    dictionary.
    
    Args:
        oauth_client_id
            The id of the oauth_client who will organize the event. The event 
            will be created for the account owning this client.
        event_name
            The name of the event
        venue_id
            The id of the venue object where this event will be held
        price
            Ticket price
        units
            Amount of tickets to be sold
        currency
            Currency of the price
            
    Returns:
        A dictionary containing the information of the newly created event
        including its identifier. A ``created`` key-value pair is added 
        indicating the success of the attempt. For example:
        
        {'created': True,
         'event': {"id": 42, 
                   "name": "Tickee Event"}
        }
         
        The dictionary will only contain the created key if the attempt was not
        successful:
        
        {'created': False}
    """
    em = logic.EventManager()
    tm = logic.TicketManager()
    sm = logic.SecurityManager()
    # create event
    try:
        if account_id is None:
            account = sm.lookup_account_for_client(oauth_client_id)
            account_id = account.id
        event = em.start_event(account_id, event_name)
        # add default eventpart
        event.venue_id = venue_id
        eventpart = em.add_eventpart(event.id, venue_id=venue_id)
        # add default ticket type
        tm.create_ticket_type(eventpart.id, price, units, currency=currency)
    except ex.TickeeError, e:
        transaction.abort()
        return marshalling.error(e)
コード例 #10
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_add_venue_to_eventpart(self):
     # Setup
     em = logic.EventManager()
     vm = logic.VenueManager()
     venue = vm.create_venue("Marktplein Lokeren")
     # Test
     em.add_venue_to_eventpart(self.eventpart.id, venue.id)
     # Validate
     self.assertEqual(self.eventpart.venue, venue,
                      "Venue was not connected successfully")
コード例 #11
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def setUp(self):
     super(EventManagementTest, self).setUp()
     # create account
     am = logic.AccountManager()
     self.account = am.create_account("Charlatan", "email")
     # create event
     em = logic.EventManager()
     self.event = em.start_event(self.account.id, "Charlatan")
     # create eventpart
     self.eventpart = em.add_eventpart(self.event.id, "Day 1")
コード例 #12
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_find_events_by_id(self):
     # Setup
     am = logic.AccountManager()
     account2 = am.create_account("account_name", "email")
     em = logic.EventManager()
     em.start_event(self.account.id, "Event 1")
     em.start_event(self.account.id, "Event 2")
     em.start_event(account2.id, "Event 3")
     # Test
     events = em.find_events(self.account.id)
     print events
     # Validate
     self.assertEqual(len(events), 2,
                      "Not all matching events were returned")
コード例 #13
0
ファイル: ticketmanager.py プロジェクト: Tickee/BLM
 def setUp(self):
     super(TicketTypeCreationTest, self).setUp()
     # Create a user
     self.user = User("email")
     Session.add(self.user)
     Session.flush()
     # Create Account
     am = logic.AccountManager()
     self.account = am.create_account("Charlatan", "email")
     # Create Event
     em = logic.EventManager()
     self.event = em.start_event(self.account.id,
                                 "Gentse Feesten @ Charlatan")
     # Create EventPart
     self.eventpart = em.add_eventpart(self.event.id)
コード例 #14
0
def show_event(event_id, include_visitors=False):
    """
    Entrypoint for showing the details of an event.
    
    Args:
        event_id
            The id of the event to show
        include_visitors
            Show all visitors of the event
            
    Returns:
        A dictionary containing event information and if required a list
        of users that purchased tickets for the event. For example:
        
        {'event': {"id": 42, 
                   "name": "Tickee Event",
                   "visitors": [{"first_name": "Kevin",
                                 "last_name": "Van Wilder"}, .. ],
                   "tickettypes": [
                       {"id": 1,
                        "name": "Ticket Name",
                        "description": "Ticket description",
                        "price": 100.00,
                        "sold_out": False}
                   ]
        }}
         
        The dictionary will contain a null event if no event found:
        
        {'event': null}
    """
    em = logic.EventManager()
    try:
        print type(event_id)
        event = em.lookup_event_by_id(int(event_id))
    except ex.EventNotFoundError:
        transaction.abort()
        return dict(event=None)
    else:
        result = dict(event=marshalling.event_to_dict(
            event, include_visitors=include_visitors,
            include_tickettypes=True))
        transaction.commit()
        return result
コード例 #15
0
def list_events(account_id=None,
                after_date=None,
                before_date=None,
                limit=10,
                past=True):
    """
    Entrypoint for finding events matching specific filters.
    
    Args:
        account_id
            Only events owned by this account
        after_date
            Only events that start after this date will be returned
        before_date
            Only events that start before this date will be returned
        limit
            Only return at most this number of events. Defaults to 10.
        past
            Show events that occurred in the past. Defaults to True.
            
    Returns:
        A dictionary containing a list of events. For example:
        
        {'events': [{"id": 42, "name": "Tickee Event"}, .. ]}
         
        The dictionary will contain an empty list if no events found:
        
        {'events': []}
    """
    em = logic.EventManager()
    event_list = em.find_events(account_id_filter=account_id,
                                after_date_filter=after_date,
                                before_date_filter=before_date,
                                limit=limit,
                                past=past)
    result = dict(events=map(marshalling.event_to_dict, event_list))
    return result
コード例 #16
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_start_event_unexisting_account(self):
     # Setup
     em = logic.EventManager()
     # Validate
     self.assertRaises(ex.AccountNotFoundError, em.start_event, 999,
                       "Event")
コード例 #17
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_add_eventpart_to_unexisting_event(self):
     # Setup
     em = logic.EventManager()
     # Validate
     self.assertRaises(ex.EventNotFoundError, em.add_eventpart, 999)
コード例 #18
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_check_if_unexisting_eventpart_exists(self):
     # Setup
     em = logic.EventManager()
     # Validate
     self.assertFalse(em.eventpart_exists(999))
コード例 #19
0
from tickee import logic
from tickee.db.models.event import Event
import sqlahelper
import tests
import tickee.exceptions as ex

Session = sqlahelper.get_session()

am = logic.AccountManager()
vm = logic.VenueManager()
tm = logic.TicketManager()
em = logic.EventManager()
om = logic.OrderManager()


class CreateEventTest(tests.BaseTestCase):
    def setUp(self):
        super(CreateEventTest, self).setUp()
        self.account = am.create_account("accountname", "email")
        self.venue = vm.create_venue("venuename")

    # init

    def test_create_event(self):
        # Test
        event = Event("name", self.venue.id, self.account.id)
        Session.add(event)
        Session.flush()
        # Validate
        self.assertIsInstance(event, Event)
        self.assertEqual(event.name, "name")
コード例 #20
0
ファイル: eventmanager.py プロジェクト: Tickee/BLM
 def test_lookup_unexisting_event_by_id(self):
     # Setup
     em = logic.EventManager()
     # Validate
     self.assertRaises(ex.EventNotFoundError, em.lookup_event_by_id, 999)