Beispiel #1
0
def set_report_announcements_for_user(request, couch_user):
    key = ["type", ReportAnnouncement.__name__]
    now = datetime.utcnow()
    data = ReportAnnouncement.get_db().view('announcements/all_announcements',
        reduce=False,
        startkey=key + [now.isoformat()],
        endkey=key + [{}],
        stale=settings.COUCH_STALE_QUERY,
    ).all()
    announce_ids = [a['id'] for a in data if a['id'] not in couch_user.announcements_seen]
    for announcement_id in announce_ids:
        try:
            announcement = ReportAnnouncement.get(announcement_id)
            if announcement.show_to_new_users or (announcement.date_created > couch_user.created_on):
                messages.info(request, announcement.as_html)
        except Exception as e:
            logging.error("Could not fetch Report Announcement: %s" % e)
Beispiel #2
0
def set_report_announcements_for_user(request, couch_user):
    key = ["type", ReportAnnouncement.__name__]
    now = datetime.utcnow()

    db = ReportAnnouncement.get_db()
    data = cache_core.cached_view(db, "announcements/all_announcements", reduce=False,
                                 startkey=key + [now.strftime("%Y-%m-%dT%H:00")], endkey=key + [{}],
                                 )

    announce_ids = [a['id'] for a in data if a['id'] not in couch_user.announcements_seen]
    for announcement_id in announce_ids:
        try:
            announcement = ReportAnnouncement.get(announcement_id)
            if announcement.show_to_new_users or (announcement.date_created > couch_user.created_on):
                messages.info(request, announcement.as_html)
        except Exception as e:
            logging.error("Could not fetch Report Announcement: %s" % e)
Beispiel #3
0
def set_report_announcements_for_user(request, couch_user):
    key = ["type", ReportAnnouncement.__name__]
    now = datetime.utcnow()

    db = ReportAnnouncement.get_db()
    data = cache_core.cached_view(db, "announcements/all_announcements", reduce=False,
                                 startkey=key + [now.strftime("%Y-%m-%dT%H:00")], endkey=key + [{}],
                                 )

    announce_ids = [a['id'] for a in data if a['id'] not in couch_user.announcements_seen]
    for announcement_id in announce_ids:
        try:
            announcement = ReportAnnouncement.get(announcement_id)
            if announcement.show_to_new_users or (announcement.date_created > couch_user.created_on):
                messages.info(request, announcement.as_html)
        except Exception as e:
            logging.error("Could not fetch Report Announcement: %s" % e)
Beispiel #4
0
def set_report_announcements_for_user(request, couch_user):
    key = ["type", ReportAnnouncement.__name__]
    now = datetime.utcnow()
    data = ReportAnnouncement.get_db().view(
        'announcements/all_announcements',
        reduce=False,
        startkey=key + [now.isoformat()],
        endkey=key + [{}],
        stale=settings.COUCH_STALE_QUERY,
    ).all()
    announce_ids = [
        a['id'] for a in data if a['id'] not in couch_user.announcements_seen
    ]
    for announcement_id in announce_ids:
        try:
            announcement = ReportAnnouncement.get(announcement_id)
            if announcement.show_to_new_users or (announcement.date_created >
                                                  couch_user.created_on):
                messages.info(request, announcement.as_html)
        except Exception as e:
            logging.error("Could not fetch Report Announcement: %s" % e)