Exemple #1
0
def broadcast_coupon(request, user=0):
    b_user = models.BarUser.for_u_id(user)
    user = b_user.user
    bar = b_user.bar
    broadcast_portlet = BroadcastPortlet(request, bar, user)
    
    if broadcast_portlet.form_success():
        return HttpResponseRedirect(h.internal_url('logged_in', user, {'broadcast_popup_success':1}))
    else:
        return HttpResponseRedirect(h.internal_url('logged_in', user, {'broadcast_popup_success':0}))
Exemple #2
0
    def test_redeem_coupon(self):
        user = m.MobileUser()
        user.save()
        old_num_remaining = self.coupon.num_remaining

        #without phone id
        self.client.get(h.internal_url('redeem_coupon', params={'coupon_id' : self.coupon.id}, action_dir='services'))
        self.assertGreater(m.CouponRedemption.objects.filter(coupon_id=self.coupon.id).count(), 0)
#        self.assertEqual(self.coupon.num_remaining, old_num_remaining - 1)

        #with phone id
        self.client.get(h.internal_url('redeem_coupon', params={'coupon_id' : self.coupon.id, 'phone_id' : user.id}, action_dir='services'))
        self.assertGreater(m.CouponRedemption.objects.filter(coupon_id=self.coupon.id).count(), 1)
        self.assertEqual(self.coupon.num_remaining, old_num_remaining - 2)
Exemple #3
0
def edit_profile(request, user=0):
    b_user = models.BarUser.for_u_id(user)
    user = b_user.user
    bar = b_user.bar
    edit_processor = EditProfileProcessor(bar, request)
        
    if edit_processor.form_success():
        return HttpResponseRedirect(h.internal_url('logged_in', user, {'selected_tab':e.NavigationTabs.PROFILE.verbose}))
    else:
        return HttpResponse(request)
Exemple #4
0
 def test_register_user(self):
     old_user_count = m.MobileUser.objects.count()
     self.client.get(h.internal_url('register_user', action_dir='services'))
     new_user_count = m.MobileUser.objects.count()
     
     self.assertEqual(new_user_count, old_user_count + 1)    #maybe not the best test
Exemple #5
0
 def test_get_coupon(self):
     self.assertEqual(self.client.get(h.internal_url('get_coupon', params={"id" : self.coupon.id}, action_dir='services')).content, 
                      json.dumps(self.coupon.to_json))
Exemple #6
0
 def test_get_bars(self):        
     self.assertEqual(self.client.get(h.internal_url('get_bars', action_dir='services')).content, self.bar.to_json)
Exemple #7
0
 def test_internal_url(self):
     INTERNAL_URL = '/drinkup/signed-in/'
     
     self.assertEquals(h.internal_url('logged_in'), '%s?' % INTERNAL_URL)
     self.assertEquals(h.internal_url('logged_in', params={'test1':True}), '%s?test1=True' % INTERNAL_URL)