def mail_sponsee_message(award, sponsor): sponsee = award.winner logging.debug("sending e-mail to %s", sponsee.email) if not mail.is_email_valid(sponsee.email): logging.error("%s is not valid", sponsee.email) return False message = mail.EmailMessage() message.sender = get_sender() message.subject = "You've earned a PlopQuiz sponsorship!" message.to = sponsee.email from model.employer import Employer this_business = Employer.get_by_key_name(sponsor.unique_identifier) sponsor_message = this_business.sponsorship_message if sponsor_message is None: sponsor_message = this_business.default_message() message.body = """ %s, You've earned a PlopQuiz sponsorship from %s for the %s quiz subject! Here is a message from %s: ------------------------------------------------------------------- %s ------------------------------------------------------------------- This sponsorship is now on your profile: %s This sponsorship is now on the profile of %s: %s %s """ % (sponsee.fullname, sponsor.fullname, award.proficiency.name.upper(), sponsor.fullname, sponsor_message, "http://" + str(os.environ['HTTP_HOST']) + "/profile/" + sponsee.profile_path, sponsor.fullname, "http://" + str(os.environ['HTTP_HOST']) + "/sponsors/" + sponsor.profile_path, mail_footer()) message.send()
def add_auto_pledge(self, *args): if not args: return "Specify A Business Identifier, Proficiency Name, and Number of Pledges." if len(args) > 3: return "Specify A Business Identifier, Proficiency Name, and Number of Pledges." business_name = args[0] from model.employer import Employer this_employer = Employer.get_by_key_name(business_name) if not this_employer: return "employer does not exist" proficiency_name = args[1] from model.proficiency import Proficiency #import string -- Capwords sucks, darnit. #this_proficiency = Proficiency.get_by_key_name(string.capwords(proficiency_name)) this_proficiency = Proficiency.get_by_key_name(proficiency_name) pledge_num = int(args[2]) from model.employer import AutoPledge new_pledge = AutoPledge(employer = this_employer, proficiency = this_proficiency, count = pledge_num) new_pledge.put() return encode(new_pledge)
def UpdateSponsorName(self, user, name): from model.employer import Employer this_sponsor = Employer.get_by_key_name(user.unique_identifier) this_sponsor.name = name return this_sponsor
from google.appengine.ext import db from .model.quiz import QuizItem, RawQuizItem, ProficiencyTopic, ContentPage, Proficiency from .utils.utils import ROOT_PATH from utils import simplejson from employer.methods import DataMethods as emp_data from google.appengine.api import images from .model.user import ProfilePicture from .model.proficiency import SubjectImage, Link from model.employer import Employer from model.account import MailingList from google.appengine.api import memcache from model.dev import Setting DATA_TYPES = {"proficiencies": Proficiency.all(), 'proficiency_topics': ProficiencyTopic.all(), 'links': Link.all(), 'content_pages': ContentPage.all(), 'raw_items' : RawQuizItem.all(), 'quiz_items': QuizItem.all(), 'mailing_list': MailingList.all(), 'employers': Employer.all(), 'settings': Setting.all()} LOAD_INCREMENT = 10 # How many entities are loaded into datastore at a time IMAGE_INCREMENT = 1 # How many entities are loaded into datastore at a time #Refresh One Data Type def refresh_data(data_type): data = DataMethods() data.delete_data(DATA_TYPES.get(data_type, False)) data.load_data(data_type, "") data.special_processes(data_type) data.execute_load() def delete_data(data_type): data = DataMethods()