예제 #1
0
    def save(self):
        resp = super(File, self).save()
        status_emails = self.deadline.status.actionstatus_set.get(
            product=self.deadline.sale.product).actionstatusemails_set.all()

        if status_emails:
            recipients = ()
            for status_email in status_emails:
                if status_email.action_email == 'own':
                    recipients += (self.deadline.sale.owner, )
                elif status_email.action_email == 'buy':
                    recipients += (self.deadline.sale.buyer.email, )
                elif status_email.action_email == 'inc':
                    recipients += (
                        self.deadline.sale.product.insurance_company.email, )
                elif status_email.action_email == 'usr':
                    for email_user in status_email.actionstatusemailsusers_set.all(
                    ):
                        recipients += (email_user.user, )

            notification = Notification(actor=self.deadline,
                                        recipient=recipients)
            notification.send(
                _('New file uploaded to Sale [#%d]') % self.deadline.sale.pk,
                _('New file uploaded to Sale [#%d] in status %s. Buyer %s, CPF/CNPJ %s'
                  ) % (self.deadline.sale.pk, self.deadline.status,
                       self.deadline.sale.buyer.name,
                       self.deadline.sale.buyer.cpf_cnpj))
        return resp
예제 #2
0
def delete(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    noti_id = request._proto.id

    n = Notification(server_id, char_id)
    n.delete(noti_id)

    response = NotificationDeleteResponse()
    response.ret = 0
    return ProtobufResponse(response)
예제 #3
0
def open(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    noti_id = request._proto.id

    n = Notification(server_id, char_id)
    n.open(noti_id)

    response = NotificationOpenResponse()
    response.ret = 0
    return ProtobufResponse(response)
예제 #4
0
def delete(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    noti_id = request._proto.id

    n = Notification(server_id, char_id)
    n.delete(noti_id)

    response = NotificationDeleteResponse()
    response.ret = 0
    return ProtobufResponse(response)
예제 #5
0
def open(request):
    server_id = request._game_session.server_id
    char_id = request._game_session.char_id

    noti_id = request._proto.id

    n = Notification(server_id, char_id)
    n.open(noti_id)

    response = NotificationOpenResponse()
    response.ret = 0
    return ProtobufResponse(response)
예제 #6
0
    def update_check():
        ''' Checks for any available updates

        Returns dict from core.version.Version.manager.update_check():
            {'status': 'error', 'error': <error> }
            {'status': 'behind', 'behind_count': #, 'local_hash': 'abcdefg', 'new_hash': 'bcdefgh'}
            {'status': 'current'}
        '''

        ver = version.Version()

        data = ver.manager.update_check()
        # if data['status'] == u'current', nothing to do.

        if data['status'] == u'error':
            notif = {
                'type': 'warning',
                'closeButton': 'true',
                'title': 'Error Checking for Updates',
                'body': data['error'],
                'params': '{closeButton: true, timeOut: 0, extendedTimeOut: 0}'
            }
            Notification.add(notif)

        elif data['status'] == u'behind':
            if data['behind_count'] == 1:
                title = u'1 Update Available'
            else:
                title = u'{} Updates Available'.format(data['behind_count'])

            compare = u'{}/compare/{}...{}'.format(core.GIT_URL,
                                                   data['local_hash'],
                                                   data['new_hash'])

            notif = {
                'type':
                'update',
                'title':
                title,
                'body':
                'Click <a href="update_now"><u>here</u></a> to update now.'
                '<br/> Click <a href="' + compare +
                '"><u>here</u></a> to view changes.',
                'params': {
                    'timeOut': 0,
                    'extendedTimeOut': 0,
                    'tapToDismiss': 0
                }
            }

            Notification.add(notif)

        return data
예제 #7
0
    def update_check():
        ''' Checks for any available updates

        Returns dict from core.version.Version.manager.update_check():
            {'status': 'error', 'error': <error> }
            {'status': 'behind', 'behind_count': #, 'local_hash': 'abcdefg', 'new_hash': 'bcdefgh'}
            {'status': 'current'}
        '''

        ver = version.Version()

        data = ver.manager.update_check()
        # if data['status'] == 'current', nothing to do.

        if data['status'] == 'error':
            notif = {
                'icon': 'fa-exclamation-triangle',
                'title': 'Error Checking for Updates',
                'text': data['error']
            }
            Notification.add(notif)

        elif data['status'] == 'behind':
            if core.CONFIG['Server']['installupdates'] == 'true':
                hour = core.CONFIG['Server']['installupdatehr']
                minute = core.CONFIG['Server']['installupdatemin']
                text = 'Updates will install automatically at {}:{}'.format(
                    hour, minute)
            else:
                text = ''

            if data['behind_count'] == 1:
                title = '1 Update Available'
            else:
                title = '{} Updates Available'.format(data['behind_count'])

            title_link = '{}/compare/{}...{}'.format(core.GIT_API,
                                                     data['new_hash'],
                                                     data['local_hash'])

            button = ('Update Now', '/update_now', 'fa-arrow-circle-up')

            notif = {
                'icon': 'fa-star',
                'title': title,
                'title_link': title_link,
                'text': text,
                'button': button
            }
            Notification.add(notif)

        return data
예제 #8
0
파일: ajax.py 프로젝트: Joecastra/Watcher3
    def notification_remove(self, index):
        ''' Removes notification from core.notification
        :param index: str or unicode index of notification to remove

        'index' will be a type of string since it comes from ajax request.
            Therefore we convert to int here before passing to Notification

        Simply calls Notification module.

        Does not return
        '''

        Notification.remove(int(index))

        return
예제 #9
0
파일: main.py 프로젝트: rajat004/py_watch
def service():
    cpu_monitor = CpuMonitor(threshold_low=CPUConstants.low.value,
                             threshold_high=CPUConstants.high.value,
                             activity_name=ActivityNames.cpu.value,
                             current_value=0)
    mem_monitor = MemoryMonitor(threshold_low=MemConstants.low.value,
                                threshold_high=MemConstants.high.value,
                                activity_name=ActivityNames.memory.value,
                                current_value=0)
    while (True):
        logger.info('sleeping at {0} !'.format(datetime.now()))
        time.sleep(REST_INTERVAL)
        logger.info('woke up at {0} !'.format(datetime.now()))
        cpu_activity = cpu_monitor.monitor_activity()
        mem_activity = mem_monitor.monitor_activity()
        Notification.send_notifications([mem_activity, cpu_activity])
예제 #10
0
 def test_delte_not_exist(self):
     try:
         Notification(1, 1).delete("xxxxx")
     except GameException as e:
         assert e.error_id == ConfigErrorMessage.get_error_id(
             "NOTIFICATION_NOT_EXIST")
     else:
         raise Exception("can not be here!")
예제 #11
0
    def save(self, *a, **kw):
        if not self.status_id:
            self.status = self.sale.product.begin_status

        if self.pk is None:
            resp = super(Deadline, self).save(*a, **kw)
            status_emails = self.status.actionstatus_set.get(
                product=self.sale.product).actionstatusemails_set.all()
            if status_emails:
                recipients = ()
                for status_email in status_emails:
                    if status_email.action_email == 'own':
                        recipients += (self.sale.owner, )
                    elif status_email.action_email == 'buy':
                        recipients += (self.sale.buyer.email, )
                    elif status_email.action_email == 'inc':
                        recipients += (
                            self.sale.product.insurance_company.email, )
                    elif status_email.action_email == 'usr':
                        for email_user in status_email.actionstatusemailsusers_set.all(
                        ):
                            recipients += (email_user.user, )

                notification = Notification(actor=self, recipient=recipients)
                notification.send(
                    _('New Sale [#%d] created') % (self.pk),
                    _('The new Sale [#%d] was created with status %s. Buyer %s, CPF/CNPJ %s '
                      ) % (self.pk, self.status, self.sale.buyer.name,
                           self.sale.buyer.cpf_cnpj))
        else:
            resp = super(Deadline, self).save(*a, **kw)
            new = Deadline.objects.get(pk=self.pk)
            if new.status != self.status:
                if new.status.actionstatus_set.filter(
                        product=self.sale.product).exists():
                    status_emails = new.status.actionstatus_set.get(
                        product=self.sale.product).actionstatusemails_set.all(
                        )
                    if status_emails:
                        recipients = ()
                        for status_email in status_emails:
                            if status_email.action_email == 'own':
                                # recipients += (self.sale.product.owner, )
                                recipients += (self.sale.owner, )
                            elif status_email.action_email == 'buy':
                                recipients += (self.sale.buyer.email, )
                            elif status_email.action_email == 'inc':
                                recipients += (self.sale.product.
                                               insurance_company.email, )
                            elif status_email.action_email == 'usr':
                                for email_user in status_email.actionstatusemailsusers_set.all(
                                ):
                                    recipients += (email_user.user, )

                        notification = Notification(actor=self,
                                                    recipient=recipients)
                        notification.send(
                            _('Sale [%d] has status changed') % (self.pk),
                            _('The Sale [%d] has status changed from %s to %s . Buyer %s, CPF/CNPJ %s '
                              ) %
                            (self.pk, self.status, new.status,
                             new.sale.buyer.name, new.sale.buyer.cpf_cnpj))

        return resp
예제 #12
0
 def test_send_notify(self):
     Notification(1, 1).send_notify()
예제 #13
0
 def test_open(self):
     Notification(1, 1).open(self.noti_id)
예제 #14
0
파일: game.py 프로젝트: zhifuliu/dianjing
def game_start_handler(server_id, char_id, **kwargs):
    MessagePipe(char_id).clean()

    msg = UTCNotify()
    msg.timestamp = arrow.utcnow().timestamp
    MessagePipe(char_id).put(msg=msg)

    msg = SocketServerNotify()
    ss = random.choice(settings.SOCKET_SERVERS)
    msg.ip = ss['host']
    msg.port = ss['tcp']
    MessagePipe(char_id).put(msg=msg)

    _Resource.send_notify(server_id, char_id)

    UnitManager(server_id, char_id).send_notify()

    Bag(server_id, char_id).send_notify()

    StaffManger(server_id, char_id).send_notify()
    StaffRecruit(server_id, char_id).send_notify()

    f = Formation(server_id, char_id)
    f.send_formation_notify()
    f.send_slot_notify()

    club = Club(server_id, char_id)
    club.set_login()
    club.send_notify()

    msg = CreateDaysNotify()
    msg.days = days_passed(club.create_at)
    msg.create_at = club.create_at
    MessagePipe(char_id).put(msg=msg)

    chall = Challenge(server_id, char_id)
    chall.send_chapter_notify()
    chall.send_challenge_notify()

    FriendManager(server_id, char_id).send_notify()
    MailManager(server_id, char_id).send_notify()

    TaskMain(server_id, char_id).send_notify()
    TaskDaily(server_id, char_id).send_notify()

    Chat(server_id, char_id).send_notify()

    Notification(server_id, char_id).send_notify()

    FinanceStatistics(server_id, char_id).send_notify()

    TalentManager(server_id, char_id).send_notify()

    Dungeon(server_id, char_id).send_notify()

    a = Arena(server_id, char_id)
    a.send_notify()
    a.send_honor_notify()

    t = Tower(server_id, char_id)
    t.send_notify()
    t.send_goods_notify()

    Territory(server_id, char_id).send_notify()
    TerritoryStore(server_id, char_id).send_notify()
    TerritoryFriend(server_id, char_id).send_remained_times_notify()

    Store(server_id, char_id).send_notify()
    VIP(server_id, char_id).send_notify()
    Collection(server_id, char_id).send_notify()

    Energy(server_id, char_id).send_notify()

    w = Welfare(server_id, char_id)
    w.send_signin_notify()
    w.send_new_player_notify()
    w.send_level_reward_notify()
    w.send_energy_reward_notify()

    Union(server_id, char_id).send_all_notify()

    Purchase(server_id, char_id).send_notify()

    ac = ActivityNewPlayer(server_id, char_id)
    ac.send_notify()
    ac.send_daily_buy_notify()

    ActivityOnlineTime(server_id, char_id).send_notify()
    ActivityChallenge(server_id, char_id).send_notify()
    ActivityPurchaseDaily(server_id, char_id).send_notify()
    ActivityPurchaseContinues(server_id, char_id).send_notify()
    ActivityLevelGrowing(server_id, char_id).send_notify()

    p = Plunder(server_id, char_id)

    p.send_search_notify()
    p.send_result_notify()
    p.send_revenge_notify()
    p.send_station_notify()
    p.send_formation_notify()
    p.send_plunder_times_notify()
    p.send_plunder_daily_reward_notify()

    SpecialEquipmentGenerator(server_id, char_id).send_notify()

    Party(server_id, char_id).send_notify()

    ins = Inspire(server_id, char_id)
    ins.try_open_slots(send_notify=False)
    ins.send_notify()

    cs = Championship(server_id, char_id)
    cs.try_initialize(send_notify=False)
    cs.send_notify()

    WinningPlunder(server_id, char_id).send_notify()
    WinningArena(server_id, char_id).send_notify()
    WinningChampionship(server_id, char_id).send_notify()
    Worship(server_id, char_id).send_notify()
    CommonArenaWinningChat(server_id, char_id).send_notify()
    CommonPlunderWinningChat(server_id, char_id).send_notify()
    CommonChampionshipChat(server_id, char_id).send_notify()

    send_system_notify(server_id, char_id)
    BroadCast(server_id, char_id).try_cast_login_notify()
예제 #15
0
 def setup(self):
     n = Notification(1, 1)
     self.noti_id = n.add_league_notification(True, "t", 1, 1, 1)
예제 #16
0
 def setup(self):
     n = Notification(1, 1)
     self.noti_id = n.add_league_notification(True, "t", 1, 1, 1)
예제 #17
0
 def test_delete(self):
     assert Notification(1, 1).has_notification(self.noti_id) is True
     Notification(1, 1).delete(self.noti_id)
     assert Notification(1, 1).has_notification(self.noti_id) is False