Exemplo n.º 1
0
def build_frame_votes():
    users = User.objects.all()
    for user in users:
        print "build frame votes for user:"******"building votes for frame:", frame.id
                frame.vote = frame.get_vote()
                frame.save()
        except ConnectionDoesNotExist:
            print 'raised ConnectionDoesNotExist for user:' + user.username
Exemplo n.º 2
0
def remind_weekly_review(users):
    now = date.today()
    #TODO:check if 5 is correct for US time.
    this_monday = now - datetime.timedelta(days=5)

    #print 'monday_this_week','Weekly Plan:'+this_monday.strftime('%Y-%m-%d')+' to '

    for user in users:
        try:
            member = Member.objects.get(username=user)
            if member.plan_notice == 'n':
                pass
            else:
                f = getFrame(user).objects.get(
                    title__startswith='Weekly Plan:' +
                    this_monday.strftime('%Y-%m-%d') + ' to ')

                pick_lang = 'zh-cn'
                if member.default_lang:
                    pick_lang = member.default_lang
                    activate(pick_lang)

                frame_url = site_name + '/' + member.username + '/framebook/notes/note/' + str(
                    f.id) + '/'
                content = _("It is the weekend again. Now is your time to review your weekly plan. Have you accomplished your plan this week? What have you done well? What you haven't done very well? What can you improve on? ")+'\n'+\
                        _("Remember to find time on the weekend to review your weekly plan:") + '\n' + \
                        frame_url + '\n\n' + \
                        _("If your weekly plan is empty this week, it will be removed for you automatically the beginning of next week:") + '\n\n' +\
                    _("If you don't want to receive any learning plan notice, you can change your preference setting:") + '\n' + \
                    setting_url


                html_content =  _("It is the weekend again. Now is your time to review your weekly plan. Have you accomplished your plan this week? What have you done well? What you haven't done very well? What can you improve on? ")+'<br/>'+\
                        _("Remember to find time on the weekend to review your weekly plan:") + '<br/>' + \
                        '<a href="' + frame_url +'">' + frame_url + '</a>' + '<br/><br/>' + \
                        _("If your weekly plan is empty this week, it will be removed for you automatically the beginning of next week:") + '<br/><br/>' +\
                   _("If you don't want to receive any learning plan notice, you can change your preference setting:") +'<br/>' +\
                   '<a href="' + setting_url +'">' + setting_url + '</a>'

                msg = EmailMultiAlternatives(
                    _('Time to review your weekly plan'),
                    content.encode('utf-8'), SERVER_EMAIL, [member.email])
                msg.attach_alternative(html_content.encode('utf-8'),
                                       "text/html")
                msg.send()
                print 'email was sent to user', user, ' for weekly plan review.'
                time.sleep(10)
        except:
            print sys.exc_info()
Exemplo n.º 3
0
def create_monthly_plan(user):
    now = date.today()
    f, created = getFrame(user).objects.get_or_create(title="Monthly Plan:" + now.strftime("%Y-%m"))
    f.owner_name = user
    f.desc = "Make your monthly plan for this month here."
    f.save()
    f_trans, trans_created = getNoteTranslation(user).objects.get_or_create(note=f)
    f_trans.owner_name = user
    f_trans.lang = "C"
    f_trans.original_lang = "E"
    f_trans.title = _("Monthly Plan:") + now.strftime("%Y-%m")
    f_trans.desc = _("Make your monthly plan for this month here.")
    f_trans.save()
    # to push the translation to the social notebook as well
    f.save()
    return f.id
Exemplo n.º 4
0
def create_monthly_plan(user):
    now = date.today()
    f, created = getFrame(user).objects.get_or_create(title='Monthly Plan:' +
                                                      now.strftime('%Y-%m'))
    f.owner_name = user
    f.desc = 'Make your monthly plan for this month here.'
    f.save()
    f_trans, trans_created = getNoteTranslation(user).objects.get_or_create(
        note=f)
    f_trans.owner_name = user
    f_trans.lang = 'C'
    f_trans.original_lang = 'E'
    f_trans.title = _('Monthly Plan:') + now.strftime('%Y-%m')
    f_trans.desc = _('Make your monthly plan for this month here.')
    f_trans.save()
    #to push the translation to the social notebook as well
    f.save()
    return f.id
Exemplo n.º 5
0
def create_weekly_plan(user):
    now = date.today()
    one_week_later = now + datetime.timedelta(days=6)
    f, created = getFrame(user).objects.get_or_create(
        title="Weekly Plan:" + now.strftime("%Y-%m-%d") + " to " + one_week_later.strftime("%Y-%m-%d")
    )
    # if created:
    f.owner_name = user
    f.desc = "Make your weekly plan for this week here."
    f.save()
    f_trans, trans_created = getNoteTranslation(user).objects.get_or_create(note=f)
    f_trans.owner_name = user
    f_trans.lang = "C"
    f_trans.original_lang = "E"
    f_trans.title = _("Weekly Plan:") + now.strftime("%Y-%m-%d") + _(" to ") + one_week_later.strftime("%Y-%m-%d")
    f_trans.desc = _("Make your weekly plan for this week here.")
    f_trans.save()
    # to push the translation to the social notebook as well
    f.save()
    return f.id
Exemplo n.º 6
0
def clean_up_monthly_plans(users):
    now = date.today()
    # at least 28 should be enough
    last_month_date = now - datetime.timedelta(days=28)
    for user in users:
        print "Cleanup monthly plans for user", user
        try:
            # get weekly plans of this month
            # assume that no one will change the init_date of the plan, or disallow changing of that for plans TODO:
            # also assume that no one will change the plan title or disallow that  TODO:
            empty_plans = getFrame(user).objects.filter(
                title__startswith="Monthly Plan:", init_date__lte=last_month_date.strftime("%Y-%m-%d"), notes=None
            )
            empty_plans.update(deleted=True)
            for p in empty_plans:
                p.save()

            empty_plans.delete()
            print "Empty monthly plans are removed for user", user
        except:
            print sys.exc_info()
Exemplo n.º 7
0
def create_weekly_plan(user):
    now = date.today()
    one_week_later = now + datetime.timedelta(days=6)
    f, created = getFrame(user).objects.get_or_create(
        title='Weekly Plan:' + now.strftime('%Y-%m-%d') + ' to ' +
        one_week_later.strftime('%Y-%m-%d'))
    #if created:
    f.owner_name = user
    f.desc = 'Make your weekly plan for this week here.'
    f.save()
    f_trans, trans_created = getNoteTranslation(user).objects.get_or_create(
        note=f)
    f_trans.owner_name = user
    f_trans.lang = 'C'
    f_trans.original_lang = 'E'
    f_trans.title = _('Weekly Plan:') + now.strftime('%Y-%m-%d') + _(
        ' to ') + one_week_later.strftime('%Y-%m-%d')
    f_trans.desc = _('Make your weekly plan for this week here.')
    f_trans.save()
    #to push the translation to the social notebook as well
    f.save()
    return f.id
Exemplo n.º 8
0
def clean_up_monthly_plans(users):
    now = date.today()
    #at least 28 should be enough
    last_month_date = now - datetime.timedelta(days=28)
    for user in users:
        print 'Cleanup monthly plans for user', user
        try:
            #get weekly plans of this month
            #assume that no one will change the init_date of the plan, or disallow changing of that for plans TODO:
            #also assume that no one will change the plan title or disallow that  TODO:
            empty_plans = getFrame(user).objects.filter(
                title__startswith='Monthly Plan:',
                init_date__lte=last_month_date.strftime('%Y-%m-%d'),
                notes=None)
            empty_plans.update(deleted=True)
            for p in empty_plans:
                p.save()

            empty_plans.delete()
            print 'Empty monthly plans are removed for user', user
        except:
            print sys.exc_info()
Exemplo n.º 9
0
def clean_up_weekly_plans(users):
    now = date.today()
    last_monday = now - datetime.timedelta(days=7)
    for user in users:
        print "Cleanup weekly plans for user", user
        try:
            # get weekly plans of this month
            # assume that no one will change the init_date of the plan, or disallow changing of that for plans TODO:
            # also assume that no one will change the plan title or disallow that  TODO:

            # update(deleted=True) will remove it from the social space first
            empty_plans = getFrame(user).objects.filter(
                title__startswith="Weekly Plan:", init_date__lte=last_monday.strftime("%Y-%m-%d"), notes=None
            )
            empty_plans.update(deleted=True)
            # call save to remove from social space
            for p in empty_plans:
                p.save()
            empty_plans.delete()
            # print fs
            print "Empty weekly plans are removed for user", user
        except:
            print sys.exc_info()
Exemplo n.º 10
0
def clean_up_weekly_plans(users):
    now = date.today()
    last_monday = now - datetime.timedelta(days=7)
    for user in users:
        print 'Cleanup weekly plans for user', user
        try:
            #get weekly plans of this month
            #assume that no one will change the init_date of the plan, or disallow changing of that for plans TODO:
            #also assume that no one will change the plan title or disallow that  TODO:

            #update(deleted=True) will remove it from the social space first
            empty_plans = getFrame(user).objects.filter(
                title__startswith='Weekly Plan:',
                init_date__lte=last_monday.strftime('%Y-%m-%d'),
                notes=None)
            empty_plans.update(deleted=True)
            #call save to remove from social space
            for p in empty_plans:
                p.save()
            empty_plans.delete()
            #print fs
            print 'Empty weekly plans are removed for user', user
        except:
            print sys.exc_info()
Exemplo n.º 11
0
def remind_monthly_review(users):
    now = date.today()

    for user in users:
        try:
            member = Member.objects.get(username=user)
            if member.plan_notice == "n":
                pass
            else:
                f = getFrame(user).objects.get(title__startswith="Monthly Plan:" + now.strftime("%Y-%m"))
                pick_lang = "zh-cn"
                if member.default_lang:
                    pick_lang = member.default_lang
                    activate(pick_lang)

                frame_url = site_name + "/" + member.username + "/framebook/notes/note/" + str(f.id) + "/"
                content = (
                    _(
                        "It is the end of the month again. Now is your time to review your monthly plan. Have you accomplished your plan this month? What have you done well? What you haven't done very well? What can you improve on? "
                    )
                    + "\n"
                    + _("Remember to find time to review your monthly plan:")
                    + "\n"
                    + frame_url
                    + "\n\n"
                    + _(
                        "If your monthly plan is empty this month, it will be removed for you automatically the beginning of next month:"
                    )
                    + "\n\n"
                    + _(
                        "If you don't want to receive any learning plan notice, you can change your preference setting:"
                    )
                    + "\n"
                    + setting_url
                )

                html_content = (
                    _(
                        "It is the end of the month again. Now is your time to review your monthly plan. Have you accomplished your plan this month? What have you done well? What you haven't done very well? What can you improve on? "
                    )
                    + "<br/>"
                    + _("Remember to find time to review your monthly plan:")
                    + "<br/>"
                    + '<a href="'
                    + frame_url
                    + '">'
                    + frame_url
                    + "</a>"
                    + "<br/><br/>"
                    + _(
                        "If your monthly plan is empty this month, it will be removed for you automatically the beginning of next month:"
                    )
                    + "<br/><br/>"
                    + _(
                        "If you don't want to receive any learning plan notice, you can change your preference setting:"
                    )
                    + "<br/>"
                    + '<a href="'
                    + setting_url
                    + '">'
                    + setting_url
                    + "</a>"
                )

                msg = EmailMultiAlternatives(
                    _("Time to review your monthly plan"), content.encode("utf-8"), SERVER_EMAIL, [member.email]
                )
                msg.attach_alternative(html_content.encode("utf-8"), "text/html")
                msg.send()
                print "email was sent to user", user, " for monthly plan review."
                time.sleep(10)
        except Exception as inst:
            print sys.exc_info()
Exemplo n.º 12
0
def remind_weekly_review(users):
    now = date.today()
    # TODO:check if 5 is correct for US time.
    this_monday = now - datetime.timedelta(days=5)

    # print 'monday_this_week','Weekly Plan:'+this_monday.strftime('%Y-%m-%d')+' to '

    for user in users:
        try:
            member = Member.objects.get(username=user)
            if member.plan_notice == "n":
                pass
            else:
                f = getFrame(user).objects.get(
                    title__startswith="Weekly Plan:" + this_monday.strftime("%Y-%m-%d") + " to "
                )

                pick_lang = "zh-cn"
                if member.default_lang:
                    pick_lang = member.default_lang
                    activate(pick_lang)

                frame_url = site_name + "/" + member.username + "/framebook/notes/note/" + str(f.id) + "/"
                content = (
                    _(
                        "It is the weekend again. Now is your time to review your weekly plan. Have you accomplished your plan this week? What have you done well? What you haven't done very well? What can you improve on? "
                    )
                    + "\n"
                    + _("Remember to find time on the weekend to review your weekly plan:")
                    + "\n"
                    + frame_url
                    + "\n\n"
                    + _(
                        "If your weekly plan is empty this week, it will be removed for you automatically the beginning of next week:"
                    )
                    + "\n\n"
                    + _(
                        "If you don't want to receive any learning plan notice, you can change your preference setting:"
                    )
                    + "\n"
                    + setting_url
                )

                html_content = (
                    _(
                        "It is the weekend again. Now is your time to review your weekly plan. Have you accomplished your plan this week? What have you done well? What you haven't done very well? What can you improve on? "
                    )
                    + "<br/>"
                    + _("Remember to find time on the weekend to review your weekly plan:")
                    + "<br/>"
                    + '<a href="'
                    + frame_url
                    + '">'
                    + frame_url
                    + "</a>"
                    + "<br/><br/>"
                    + _(
                        "If your weekly plan is empty this week, it will be removed for you automatically the beginning of next week:"
                    )
                    + "<br/><br/>"
                    + _(
                        "If you don't want to receive any learning plan notice, you can change your preference setting:"
                    )
                    + "<br/>"
                    + '<a href="'
                    + setting_url
                    + '">'
                    + setting_url
                    + "</a>"
                )

                msg = EmailMultiAlternatives(
                    _("Time to review your weekly plan"), content.encode("utf-8"), SERVER_EMAIL, [member.email]
                )
                msg.attach_alternative(html_content.encode("utf-8"), "text/html")
                msg.send()
                print "email was sent to user", user, " for weekly plan review."
                time.sleep(10)
        except:
            print sys.exc_info()