def add_update(link, val): # future: find downloads, age, comment soup = get_soup(link) name = get_name(soup) creator = get_creator(soup) platform = get_platform(soup) subject = get_subject(soup) if subject == 'NotEducation': # change to "creator == 'NotEducation', set in classifier" print "The app '%s' is not Education-related and was not added to the database!" % name else: price = get_price(soup) rating = get_rating(soup) artwork = get_artwork(soup) if val == 0: m1 = Apps(name=name, platform=platform, creator=creator, subject=subject, price=price, rating=rating, artwork=artwork, link=link, date_added=datetime.datetime.now()) m1.save() print "The app '%s' was successfully added to the database!" % name elif val == 1: m1 = Apps.objects.filter(link=link) m1.update(name=name, platform=platform, creator=creator, subject=subject, price=price, rating=rating, artwork=artwork, link=link) print "The app '%s' was successfully updated!" % name else: print "What the hell are you doing with your code!?"
def add_update(link, val): # future: find downloads, age, comment soup = get_soup(link) name = get_name(soup) creator = get_creator(soup) platform = get_platform(soup) subject = get_subject(soup) if subject == 'NotEducation': # change to "creator == 'NotEducation', set in classifier" print "The app '%s' is not Education-related and was not added to the database!" % name else: price = get_price(soup) rating = get_rating(soup) artwork = get_artwork(soup) if val == 0: m1 = Apps(name=name, platform=platform, creator=creator, subject=subject, price=price, rating=rating, artwork=artwork, link=link, date_added=datetime.datetime.now()) m1.save() print "The app '%s' was successfully added to the database!" % name elif val == 1: m1 = Apps.objects.get(link=link) m1.update(name=name, platform=platform, creator=creator, subject=subject, price=price, rating=rating, artwork=artwork, link=link) print "The app '%s' was successfully updated!" % name else: print "What the hell are you doing with your code!?"