예제 #1
0
def update_latest_builds(user, app_id, date, version):
    """
    determines whether to update the last build attributes in a user's reporting metadata
    """
    last_builds = filter(
        lambda build: build.app_id == app_id,
        user.reporting_metadata.last_builds,
    )
    if last_builds:
        assert len(last_builds) == 1, 'Must only have one last build per app'
        last_build = last_builds[0]
    else:
        last_build = None

    if _last_build_needs_update(last_build, date):
        if last_build is None:
            last_build = LastBuild()
            user.reporting_metadata.last_builds.append(last_build)
        last_build.build_version = version
        last_build.app_id = app_id
        last_build.build_version_date = date

    if _last_build_needs_update(user.reporting_metadata.last_build_for_user,
                                date):
        user.reporting_metadata.last_build_for_user = last_build
예제 #2
0
파일: util.py 프로젝트: ye-man/commcare-hq
def update_latest_builds(user, app_id, date, version):
    """
    determines whether to update the last build attributes in a user's reporting metadata
    """
    from corehq.apps.users.models import LastBuild
    last_build = filter_by_app(user.reporting_metadata.last_builds, app_id)
    changed = False
    if _last_build_needs_update(last_build, date):
        if last_build is None:
            last_build = LastBuild()
            user.reporting_metadata.last_builds.append(last_build)
        last_build.build_version = version
        last_build.app_id = app_id
        last_build.build_version_date = date
        changed = True

    if _last_build_needs_update(user.reporting_metadata.last_build_for_user, date):
        user.reporting_metadata.last_build_for_user = last_build
        changed = True

    return changed