def create_company():
    company = Company()
    company_data = json.loads(request.data)
    update_company_data(company, company_data)
    db_session.add(company)
    db_session.commit()
    return jsonify(company.to_dict())
Exemple #2
0
 def test_cascading_deletes(self):
     company = Company(name=self.random(), url = self.random())
     company.put()
     
     show_url = self.random()
     show = Show(name= self.random(), url = show_url, company = company)
     show.put()
     
     self.assertTrue(Show.get_by_url(show_url))
     company.delete()
     self.assertFalse(Show.get_by_url(show_url))
Exemple #3
0
class ExtendedTestCase(unittest.TestCase): 
    public_app = TestApp(public_main.createApp())
    admin_app = TestApp(admin_main.createApp())
    _login_stubs = StubOutForTesting()
    stubs = StubOutForTesting()
    
    def random(self):
        import hashlib, time
        return hashlib.md5((time.clock()*random.random()).__str__()).hexdigest()
    
    def setUp(self):
        self.make_test_data()
        self.login()
        self.mox = Mox()
      
    def tearDown(self):
        self.logout()
        self.stubs.UnsetAll()
        for model in [City, Company, Performance, Show, Venue]:
            for datum in model.all():
                datum.delete()

    def login(self, user="******", admin=True):
        self._login_stubs.Set(users, 'get_current_user', lambda user = user : users.User(user))
        self._login_stubs.Set(users, 'is_current_user_admin', lambda admin = admin : admin)

    def logout(self):
        self._login_stubs.UnsetAll()

    def make_test_data(self):
        now = datetime.datetime.now()
        self.now = datetime.datetime(year = now.date().year, month = now.date().month, day = now.date().day, hour = now.time().hour, minute = now.time().minute)
        self.one_day_later = self.now + datetime.timedelta(days=1)
        self.two_days_later = self.now + datetime.timedelta(days=2)
        self.three_days_later = self.now + datetime.timedelta(days=3)
        
        self.evam = Company(name='Evam Theatre Company', url='evam')
        self.evam.put()
        self.hamlet = Show(name='Hamlet', url='hamlet', company=self.evam)
        self.hamlet.put()
        self.chennai = City(name='Chennai', url='chennai')
        self.chennai.put()
        self.bangalore = City(name='Bangalore', url='bangalore')
        self.bangalore.put()
        self.lady_andal = Venue(name='Lady Andal', url='lady_andal', city=self.chennai)
        self.lady_andal.put()
        
    def make_performance(self, show, venue, dt):
        perf = Performance(show=show, venue=venue, utc_date_time=dt)
        perf.put()
        return perf
Exemple #4
0
 def test_company_delete(self):
     company_route = '/_admin/company'
     url = self.random()
     Company(name = self.random(), url = url, description = 'desc').put()
     company_data = dict(action='delete')
     self.admin_app.post(company_route+'/'+url, company_data)
     self.assertFalse(Company.get_by_url(url))
Exemple #5
0
 def update(self, company_url= None):
     company = Company.get_by_url(company_url)
     if company:
         company.name = self.read('name')
         company.url = self.read('url')
         company.description = self.read('description')
         company.put()
     self.redirect('/_admin/company')
Exemple #6
0
 def get(self, company_url, show_url):
     company = Company.get_by_url(company_url)
     if company: show = company.get_show_by_url(show_url)
     else:
         self.redirect('/', False)
         return
     if not show:
         self.redirect('/' + company_url, False)
         return
     performances = show.get_performances().fetch(50)
     self.render('public/show.html', dict(show=show, performances=performances, auth = utils.authdetails(show.get_route())))
Exemple #7
0
 def test_company_creation(self):
     company_route = '/_admin/company'
     self.admin_app.post(company_route, {'action':'create'}, status=403) # tells blank posts to bugger off 
     name = self.random()
     url = self.random()
     
     company_data = dict(action='create', name=name, url=url)
     self.admin_app.post(company_route, company_data)
     self.admin_app.post(company_route, company_data, status=403) # create the city only once
     
     company = Company.get_by_url(url)
     self.assertTrue(company)
     self.assertEqual(name, company.name)
     self.assertEqual(url, company.url)
Exemple #8
0
 def test_company_editing(self):
     company_route = '/_admin/company'
     url = self.random()
     Company(name = self.random(), url = url, description = 'desc').put()
     
     new_name = self.random()
     new_url = self.random()
     new_desc = self.random()
     
     company_data = dict(action='update', name=new_name, url=new_url, description = new_desc)
     self.admin_app.post(company_route+'/'+url, company_data)
     company = Company.get_by_url(new_url)
     self.assertEqual(new_name, company.name)
     self.assertEqual(new_url, company.url)
     self.assertEqual(new_desc,company.description)
Exemple #9
0
 def make_test_data(self):
     now = datetime.datetime.now()
     self.now = datetime.datetime(year = now.date().year, month = now.date().month, day = now.date().day, hour = now.time().hour, minute = now.time().minute)
     self.one_day_later = self.now + datetime.timedelta(days=1)
     self.two_days_later = self.now + datetime.timedelta(days=2)
     self.three_days_later = self.now + datetime.timedelta(days=3)
     
     self.evam = Company(name='Evam Theatre Company', url='evam')
     self.evam.put()
     self.hamlet = Show(name='Hamlet', url='hamlet', company=self.evam)
     self.hamlet.put()
     self.chennai = City(name='Chennai', url='chennai')
     self.chennai.put()
     self.bangalore = City(name='Bangalore', url='bangalore')
     self.bangalore.put()
     self.lady_andal = Venue(name='Lady Andal', url='lady_andal', city=self.chennai)
     self.lady_andal.put()
Exemple #10
0
 def get(self, url):
     city = City.get_by_url(url)
     if not city: company = Company.get_by_url(url)
     
     if not city and not company:
         self.redirect('/', False)
         return
     
     data_type = 'city' if city else 'company'
     data = city or company
     start_after = self.read('start_after')
     performances = data.get_performances(start_after = start_after).fetch(PAGE+1)
     start_after = performances[-2].time_sort if len(performances) == PAGE+1 else None
     render_data = dict(performances=performances[:PAGE], 
                     start_after = start_after,
                     auth = utils.authdetails(data.get_route()))
     render_data[data_type] = data 
     
     self.render('public/' + data_type + '.html', render_data)
Exemple #11
0
def create_company(company_info):
    return Company(**company_info)
Exemple #12
0
 def get(self, show_url = None):
     show = Show.get_by_url(show_url)
     self.render('admin/show.html', dict(shows = Show.all(), companies = Company.all(), current_show = show))
def update_company(id):
    name = request.form["name"]
    company = Company(name, id)
    company_repository.update(company)
    return redirect("/companies")
from models.tag import Tag
import repositories.tag_repository as tag_repository

from models.budget import Budget
import repositories.budget_repository as budget_repository

transaction_repository.delete_all()
company_repository.delete_all()
tag_repository.delete_all()
budget_repository.delete_all()

total_budget = Budget(0.00)
budget_repository.save(total_budget)

company_1 = Company("RailScot")
company_repository.save(company_1)

company_2 = Company("Pilot Beer")
company_repository.save(company_2)

company_3 = Company("WideNation")
company_repository.save(company_3)

company_4 = Company("Blub")
company_repository.save(company_4)

company_5 = Company("Amoosin Primula")
company_repository.save(company_5)

company_6 = Company("Blumen Ecke")
Exemple #15
0
 def check_company(self):
     company = Company.get_by_url(self.read('company'))
     if not company: raise Exception("That company doesn't exist.")
     return company
Exemple #16
0
 def delete(self, company_url=None):
     company = Company.get_by_url(company_url)
     if company: company.delete()
     self.get()
Exemple #17
0
 def get(self, company_url=None):
     company = Company.get_by_url(company_url)
     self.render('admin/company.html', dict(companies=Company.all(), current_company = company))
Exemple #18
0
 def resolve_company(root, info, _id):
     return CompanyModel.find_by_id(_id)
def create_company():
    name = request.form["name"]
    new_company = Company(name)
    company_repository.save(new_company)
    return redirect("/companies")
Exemple #20
0
 def resolve_company_list(root, info):
     return CompanyModel.find_all()