Example #1
0
def accounts_index(request):
    user = request.user

    infos = get_user_fav_infos(user)
    infos['vlog'] = UserFeed().items({'user': user, 'options': {}})

    return infos
Example #2
0
def process_emails(profiles, only_if_vlogs=False):
    for profile in profiles:
        now = datetime.now()
        user = profile.user

        vlogs = get_account_versionlogs(profile)
        vlogs = vlogs.filter(
            datetime__gt=profile.last_email,
            overlay="",  # only upstream versions
            action=VersionLog.VERSION_ADDED,  # only adds
        )
        if profile.email_ignore_pre:
            vlogs = vlogs.exclude(vtype__in=gentoo_unstable)
        if profile.email_ignore_pre_if_stable:
            vlogs = vlogs.exclude(
                ~Q(package__last_version_gentoo__vtype__in=gentoo_unstable),
                vtype__in=gentoo_unstable
            )

        if only_if_vlogs and not vlogs.count():
            continue

        vlogs = vlogs.order_by("-datetime")

        infos = get_user_fav_infos(user)
        infos["user"] = user
        infos["vlogs"] = vlogs

        mail_text = render_to_string(
            "euscan/accounts/euscan_email.txt",
            infos
        )

        send_user_email.delay(
            user.email, "euscan updates - %s" % str(now.date()), mail_text
        )

        profile.last_email = now
        profile.save(force_update=True)
    return True
Example #3
0
def process_emails(profiles, only_if_vlogs=False):
    for profile in profiles:
        now = datetime.now()
        user = profile.user

        vlogs = get_account_versionlogs(profile)
        vlogs = vlogs.filter(
            datetime__gt=profile.last_email,
            overlay="",  # only upstream versions
            action=VersionLog.VERSION_ADDED,  # only adds
        )
        if profile.email_ignore_pre:
            vlogs = vlogs.exclude(vtype__in=gentoo_unstable)
        if profile.email_ignore_pre_if_stable:
            vlogs = vlogs.exclude(
                ~Q(package__last_version_gentoo__vtype__in=gentoo_unstable),
                vtype__in=gentoo_unstable)

        if only_if_vlogs and not vlogs.count():
            continue

        vlogs = vlogs.order_by("-datetime")

        infos = get_user_fav_infos(user)
        infos["user"] = user
        infos["vlogs"] = vlogs

        mail_text = render_to_string("euscan/accounts/euscan_email.txt", infos)

        send_user_email.delay(user.email,
                              "euscan updates - %s" % str(now.date()),
                              mail_text)

        profile.last_email = now
        profile.save(force_update=True)
    return True