Esempio n. 1
0
def add_location():
    '''Checks if a location exists and creates a default location
    called `Home` if none exist. '''
    loc = models.Location.objects.all()
    if len(loc) > 0:
        #print "Location exists: %s" % loc[0].name
        pass
    else:
        loc = models.Location(name="Home", defaultlocation=True)
        loc.save()
Esempio n. 2
0
def add_location(locStr):
    """Checks if a location exists and creates a location
    called <locStr> if none exist. """
    loc = models.Location.objects.all()
    for l in loc:
        if l.name in locStr:
            print("Location exists: %s" % l.name)
            return

    loc = models.Location(name=locStr)
    loc.save()
    print("Location Saved: %s" % locStr)
    return