app/soc/models/seed_db.py
changeset 1789 6f112b2ebd1f
parent 1623 8b70d6bb3f8f
child 1791 26fa036d68a0
equal deleted inserted replaced
1788:f7665077a54f 1789:6f112b2ebd1f
    26 import itertools
    26 import itertools
    27 
    27 
    28 from google.appengine.api import users
    28 from google.appengine.api import users
    29 from google.appengine.api import memcache
    29 from google.appengine.api import memcache
    30 from google.appengine.ext import db
    30 from google.appengine.ext import db
       
    31 
       
    32 from django import http
    31 
    33 
    32 from soc.logic.models.ranker_root import logic as ranker_root_logic
    34 from soc.logic.models.ranker_root import logic as ranker_root_logic
    33 from soc.models import student_proposal
    35 from soc.models import student_proposal
    34 from soc.models.document import Document
    36 from soc.models.document import Document
    35 from soc.models.host import Host
    37 from soc.models.host import Host
   321   site.home = home_document
   323   site.home = home_document
   322   site.put()
   324   site.put()
   323 
   325 
   324   memcache.flush_all()
   326   memcache.flush_all()
   325 
   327 
   326   return
   328   return http.HttpResponse('Done')
   327 
   329 
   328 
   330 
   329 def clear(*args, **kwargs):
   331 def clear(*args, **kwargs):
   330   """Removes all entities from the datastore.
   332   """Removes all entities from the datastore.
   331   """
   333   """
   348   for entity in entities:
   350   for entity in entities:
   349     entity.delete()
   351     entity.delete()
   350 
   352 
   351   memcache.flush_all()
   353   memcache.flush_all()
   352 
   354 
   353   return
   355   return http.HttpResponse('Done')
       
   356 
   354 
   357 
   355 def reseed(*args, **kwargs):
   358 def reseed(*args, **kwargs):
   356   """Clears and seeds the datastore.
   359   """Clears and seeds the datastore.
   357   """
   360   """
   358 
   361 
   359   clear(*args, **kwargs)
   362   clear(*args, **kwargs)
   360   seed(*args, **kwargs)
   363   seed(*args, **kwargs)
       
   364 
       
   365   return http.HttpResponse('Done')