def __init__(self, question_author, question_to, body, short_id, slug, timestamp=datetime.datetime.now(), is_answered=False, is_anonymous=False, is_ignored=False, public=False, deleted=False, moderated_by=None, lat=None, lon=None, location_name=None, country_name=None, country_code=None, id=None, score=0, added_by=None, flag=1, ip=None, domain_name=None, page_url=None, app_id=None, open_question=False): self.id = get_item_id() self.question_author = question_author self.question_to = question_to self.body = body self.short_id = short_id self.slug = slug self.timestamp = timestamp self.is_answered = is_answered self.is_anonymous = is_anonymous self.is_ignored = is_ignored self.public = public self.deleted = deleted self.moderated_by = moderated_by self.lat = lat self.lon = lon self.location_name = location_name self.country_name = country_name self.country_code = country_code self.score = score self.added_by = added_by self.moderated_by = moderated_by self.flag = flag self.ip = ip self.domain_name = domain_name self.page_url = page_url self.app_id = app_id self.open_question = open_question
def __init__(self, question, question_author, answer_author, media_url, thumbnail_url, client_id, timestamp=datetime.datetime.now(), answer_type='video', score=0, deleted=False, ready=True, popular=False, lat=None, lon=None, location_name=None, country_name=None, country_code=None, id=None, view_count=0, show_after = 0, added_by=None, moderated_by=None, ip=None, app_id=None): self.id = get_item_id() self.question = question self.question_author = question_author self.answer_author = answer_author self.media_url = media_url self.thumbnail_url = thumbnail_url self.client_id = client_id self.timestamp = timestamp self.answer_type = answer_type self.score = score self.deleted = deleted self.ready = ready self.popular = popular self.lat = lat self.lon = lon self.location_name = location_name self.country_name = country_name self.country_code = country_code self.view_count = 0 self.show_after = show_after self.added_by = added_by self.moderated_by = moderated_by self.ip = ip self.app_id = app_id
def __init__(self, user, action, foreign_data, for_notification=None, notification_sent=False, event_time=datetime.datetime.now(), event_date=datetime.date.today, id=get_item_id()): self.id = get_item_id() self.user = user self.action = action self.foreign_data = foreign_data self.event_time = event_time self.for_notification = for_notification or consider_for_notification[action] self.notification_sent = notification_sent self.event_date = event_date
def __init__(self, notification_id, user_id, list_type, push_at=datetime.datetime.now(), seen_at=None, seen_type=None, added_at=datetime.datetime.now(), show_on='all', id=get_item_id()): self.id = id self.notification_id = notification_id self.user_id = user_id self.push_at = push_at self.list_type = list_type self.seen_at = seen_at self.seen_type = seen_type self.added_at = added_at self.show_on = show_on
def __init__(self, notification_id, user_id, device_id, push_id, added_at=datetime.datetime.now(), pushed_at=None, clicked_at=None, source='application', cancelled=False, result=None, id=get_item_id()): self.id = id self.notification_id = notification_id self.user_id = user_id self.device_id = device_id self.push_id = push_id self.added_at = added_at self.pushed_at = pushed_at self.clicked_at = clicked_at self.source = source self.cancelled = cancelled self.result = result
def notification_logger(nobject, for_users, manual=False, created_at=datetime.datetime.now(), list_type='me', push_at=None,k=None): notification = Notification(type=nobject['notification_type'], text=nobject['text'], link=nobject['link'], object_id=nobject['object_id'], icon=nobject['icon'], created_at=created_at, manual=manual, id=get_item_id()) db.session.add(notification) db.session.commit() user_notification.add_notification_for_user(notification_id=notification.id, for_users=for_users, list_type=list_type, push_at=push_at,k=k) return notification
def add_notification_for_user(notification_id, for_users, list_type, push_at=datetime.datetime.now(),k=None): for user_id in for_users: user_notification = UserNotification(notification_id=notification_id, user_id=user_id, list_type=list_type, push_at=push_at, seen_at=None, seen_type=None, added_at=datetime.datetime.now(), show_on='all', id=get_item_id() ) db.session.add(user_notification) db.session.commit() if push_at: push.send(notification_id, user_id, k)
def __init__(self, name, twitter_handle, email, twitter_text, mail_text, bio, gender, user_title, mail_subject, profile_picture=None, max_invite_count=1000, id=None, active=False): self.id = get_item_id() self.name = name self.twitter_handle = twitter_handle self.email = email self.profile_picture = profile_picture self.gender = gender self.user_title = user_title self.max_invite_count = max_invite_count self.twitter_text = twitter_text self.mail_text = mail_text self.bio = bio self.mail_subject = mail_subject self.active = active
def __init__(self, on_post, comment_author, body, timestamp=datetime.datetime.now(), deleted=False, lat=None, lon=None, location_name=None, country_name=None, country_code=None, id=None, ip=None, domain_name=None, page_url=None, app_id=None): self.id = get_item_id() self.on_post = on_post self.comment_author = comment_author self.body = body self.timestamp = timestamp self.deleted = deleted self.lat = lat self.lon = lon self.location_name = location_name self.country_name = country_name self.country_code = country_code self.ip = ip self.domain_name = domain_name self.page_url = page_url self.app_id = app_id
def __init__(self, type, text, link, object_id, icon, created_at=datetime.datetime.now(), manual=False, id=get_item_id()): if not self._type_is_valid(type): raise Exception('type should be of format <object>-<action>') self.id = id self.type = type self.text = text self.link = link self.object_id = object_id self.icon = icon, self.created_at = created_at self.manual = manual
def __init__(self, email, username, first_name, registered_with, password=None, facebook_id=None, twitter_id=None, google_id=None, bio=None, gender=None, profile_picture=None, profile_video=None, cover_picture=None, facebook_token=None, facebook_write_permission=False, twitter_token=None, twitter_secret=None, twitter_write_permission=False, google_token=None, deleted=False, monkness=-1, user_type=0, user_title=None, lat=None, lon=None, location_name=None, country_name=None, country_code=None, user_since=datetime.datetime.now(), last_updated=datetime.datetime.now(), last_seen=datetime.datetime.now(), allow_anonymous_question=True, notify_like=True, notify_follow=True, notify_question=True, notify_comments=True, notify_mention=None, notify_answer=None, timezone=0, id=None, phone_num=None, view_count=0, total_view_count=0, added_by=None, ip=None, app_id=None, domain_name=None, page_url=None, twitter_handle=None): self.id = get_item_id() self.email = email self.first_name = first_name self.username = username self.registered_with = registered_with self.password = password self.facebook_id = facebook_id self.twitter_id = twitter_id self.google_id = google_id self.bio = bio self.gender = gender self.profile_picture = profile_picture self.profile_video = profile_video self.cover_picture = cover_picture self.facebook_token = facebook_token self.facebook_write_permission = facebook_write_permission self.twitter_token = twitter_token self.twitter_secret = twitter_secret self.twitter_write_permission = twitter_write_permission self.google_token = google_token self.deleted = deleted self.monkness = monkness self.user_type = user_type self.user_title = user_title self.lat = lat self.lon = lon self.location_name = location_name self.country_name = country_name self.country_code = country_code self.user_since = user_since self.last_updated = last_updated self.last_seen = last_seen self.allow_anonymous_question = allow_anonymous_question self.notify_like = notify_like self.notify_follow = notify_follow self.notify_question = notify_question self.notify_comments = notify_comments self.notify_mention = notify_mention self.notify_answer = notify_answer self.timezone = timezone self.phone_num = phone_num self.view_count = view_count self.total_view_count = total_view_count self.added_by = added_by self.ip = ip self.app_id = app_id self.domain_name = domain_name self.page_url = page_url self.twitter_handle = twitter_handle
def send(notification_id, user_id, k=None, source='application', notification_limit=config.GLOBAL_PUSH_NOTIFICATION_DAY_LIMIT): devices = util.get_active_mobile_devices(user_id) should_push = util.count_of_push_notifications_sent(user_id=user_id) \ <= notification_limit notification = Notification.query.get(notification_id) ''' Only if the user has valid devices to be pushed to and is under global limit for the same''' if len(devices) and should_push: print 'Still under limits for number of daily notifications' k = key[notification.type] if k is None else k group_id = '-'.join([str(notification.type), str(notification.object_id)]) for device in devices: print 'Found valid devices for push notifications' user_push_notification = UserPushNotification(notification_id=notification_id, user_id=user_id, device_id=device.device_id, push_id=device.push_id, added_at=datetime.datetime.now(), pushed_at=datetime.datetime.now(), clicked_at=None, source=source, cancelled=False, result=None, id=get_item_id()) db.session.add(user_push_notification) db.session.commit() payload = { "user_to": user_id, "type": 1, "id": user_push_notification.id, "notification_id": notification.id, "heading": k['title'], "text": notification.text.replace('<b>', '').replace('</b>', ''), "styled_text": notification.text, "icon_url": notification.icon, "cover_image": None, "group_id": group_id, "link": notification.link, "deeplink": notification.link, "timestamp": int(time.mktime(user_push_notification.added_at.timetuple())), "seen": False, "label_one": k['label_one'], "label_two": k['label_two'] } if get_device_type(device.device_id) == 'android': print 'pushing gcm for android' gcm_sender = GCM() gcm_sender.send_message([device.push_id], payload) if get_device_type(device.device_id) == 'ios': print 'pushing for iOS' print 'For Push id', device.push_id apns = APN() payload = get_payload_apns(payload=payload) print payload apns.send_message([device.push_id], payload)
def __init__(self, email_id, mail_type, object_id): self.id = get_item_id() self.email_id = email_id self.mail_type = mail_type self.object_id = object_id
def __init__(self): self.id = get_item_id()
def __init__(self, username): self.id = get_item_id() self.username = username