Beispiel #1
0
 def handle_noargs(self, **options):
     """
     clean pushes, get latest of each distinct object and mark as pushed
     """
     
     print "Initializing Nudge"
     print "  - Deleting all batches and batch items"
     Batch.objects.all().delete()
     BatchItem.objects.all().delete()
     
     print "  - Generating initial key"
     settings, created = Setting.objects.get_or_create(pk=1)
     new_key= generate_key()
     settings.local_key=new_key
     settings.save()
     
     print "  - Creating silent batch"
     silent = Batch(title="Nudge Initialization")
     silent.save()
     
     print "  - Adding objects to batch"
     latest = latest_objects()
     for l in latest:
         batch_item = BatchItem(object_id=l.object_id, version=l, batch=silent)
         batch_item.save()
         
     print "  - Marking batch as pushed"
     silent.pushed = datetime.datetime.now()
     silent.save()
Beispiel #2
0
def add_versions_to_batch(batch, versions):
    """takes a list of Version obects, and adds them to the given Batch"""
    for v in versions:
        item = BatchItem(object_id=v.object_id, version=v, batch=batch)
        item.save()
Beispiel #3
0
def add_versions_to_batch(batch, versions):
    """Takes a list of Version objects, and adds them to the given Batch"""
    for v in versions:
        item = BatchItem(version=v, batch=batch)
        item.save()