Beispiel #1
0
def save_tips():
    for tdata in iterate_file("tip", shortcircuit=True):
        tip = Tip()
        tip.business_id = tdata['business_id']
        tip.text = tdata['text']
        tip.user_id = tdata['user_id']
        tip.date = datetime.strptime(tdata['date'], "%Y-%m-%d")
        tip.likes = int(tdata['likes'])
        tip.save()
def save_tips():
    for tdata in iterate_file("tip", shortcircuit=True):
        tip = Tip()
        tip.business_id = tdata['business_id']
        tip.text = tdata['text']
        tip.user_id = tdata['user_id']
        tip.date = datetime.strptime(tdata['date'], "%Y-%m-%d")
        tip.likes = int(tdata['likes'])
        tip.save()
Beispiel #3
0
 def save(self):
     registration = self.cleaned_data.get('registration')
     match = self.cleaned_data.get('match')
     tipped_team = self.cleaned_data.get('tipped_team')
     try:
         tip = Tip.objects.get(registration=registration, match=match)
     except Tip.DoesNotExist:
         tip = Tip(registration=registration, match=match)
     tip.winner = tipped_team
     tip.save()
     return tip
Beispiel #4
0
def save_tips():
    for tdata in iterate_file("tip", shortcircuit=True):
        tip = Tip()
        tip.business_id = tdata['business_id']
        tip.text = tdata['text']
        tip.user_id = tdata['user_id']
        tip.date = datetime.strptime(tdata['date'], "%Y-%m-%d")
        tip.likes = int(tdata['likes'])
        try:
            tip.save()
        except InternalError:
            print "i dont care"
            pass
Beispiel #5
0
def add_tip(request):
    target_model = request.POST.get('model', '').lower()
    target_name = request.POST.get('id', '').lower()
    tip = request.POST.get('tip', '').lower()
    errors = []

    if target_model.strip() and target_name.strip():
        cleaned_tip = tip.strip()
        tip_object = Tip(target_model=target_model,
                         target_name=target_name,
                         tip=cleaned_tip)
        tip_object.save()

    response = {'success': True, 'errors': errors}
    return shortcuts.render_to_response(
        'json.html', {'response': json.dumps(response)},
        context_instance=RequestContext(request),
        mimetype="application/json")
Beispiel #6
0
def add_tip(request):
    target_model = request.POST.get('model', '').lower()
    target_name = request.POST.get('id', '').lower()
    tip = request.POST.get('tip', '').lower()
    errors = []
    
    if target_model.strip() and target_name.strip():
        cleaned_tip = tip.strip()
        tip_object = Tip(target_model = target_model, 
                         target_name = target_name, 
                         tip = cleaned_tip)
        tip_object.save()
    
    response = {'success':True, 'errors':errors}
    return shortcuts.render_to_response('json.html',
                                         {'response':json.dumps(response)},
                                         context_instance = RequestContext(request),
                                         mimetype = "application/json")