def SetCountiesForEvent(event_id, counties): event = Event.get_by_id(event_id) event.counties = [county for county in counties] event.latitudes = [] event.longitudes = [] cache.PutAndCache(event, ten_minutes) return True
def AddSiteToEvent(site, event_id, force=False, can_overwrite=False): event = Event.get_by_id(event_id) if not site or not event or ((not force and not can_overwrite) and site.event): logging.critical("Could not initialize site: " + str(site.key().id())) return False site.event = event site.case_number = event.case_label + str(event.num_sites) event.num_sites += 1 cache.PutAndCache(event, ten_minutes) site.compute_similarity_matching_fields() site.put() return True
def AuthenticatedPost(self, org, event): if not org.name == GLOBAL_ADMIN_NAME: self.redirect("/") return data = event_db.NewEventForm(self.request.POST) if not data.validate(): query_string = "SELECT * FROM Event" events_list = db.GqlQuery(query_string) count = events_list.count() self.response.out.write( template.render({ "form": data, "errors": data.errors, "case_label": CASE_LABELS[count], })) else: query_string = "SELECT * FROM Event" events_list = db.GqlQuery(query_string) count = events_list.count() this_event = event_db.Event( name=data.name.data, short_name=data.short_name.data, case_label=CASE_LABELS[count], ) ten_minutes = 600 cache.PutAndCache(this_event, ten_minutes) # create local admin new_admin = organization.Organization( name="Local Admin - " + data.short_name.data, email="", phone="", address="", city="", state="", zip_code="", physical_presence=True, number_volunteers="0", voad_member=False, org_verified=True, twitter="", url="", facebook="", incidents=[this_event.key()], password=self.request.get("password"), is_active=True, is_admin=True, ) organization.PutAndCache(new_admin, ten_minutes) self.redirect("/admin")
def AuthenticatedGet(self, org, event): global_admin = False if org.name == GLOBAL_ADMIN_NAME: global_admin = True if global_admin == False: self.redirect("/") return org_id = self.request.get("organization") contact_id = self.request.get("contact") int_org_id = int(org_id) int_contact_id = int(contact_id) this_organization = organization.Organization.get_by_id(int_org_id) this_contact = primary_contact_db.Contact.get_by_id(int_contact_id) this_organization.is_admin = True cache.PutAndCache(this_organization, 600) self.redirect("/admin?message=Admin Added")
def ReduceNumberOfSitesFromEvent(event_id): event = Event.get_by_id(event_id) event.num_sites -= 1 cache.PutAndCache(event, ten_minutes)