Exemple #1
0
 def display_events(self, lhs, rhs):
     if lhs:
         self.display_event(lhs)
         return
     now = utcnow()
     interval = duration_from_string('6h')
     expired = now - interval
     events = Event.objects.filter(date_schedule__gte=expired).order_by('date_schedule')
     tz = self.player.settings.get('timezone')
     last_day = ''
     check_day = ''
     message = list()
     message.append(self.player.render.header("Current Schedule - %s" % self.player.time.display(format='%Z')))
     for event in events:
         check_day = self.caller.display_local_time(date=event.date_schedule, format='%a %b %d %Y')
         if check_day != last_day:
             message.append(self.player.render.subheader(check_day))
         last_day = check_day
         time = self.caller.display_local_time(date=event.date_schedule, format='%I:%M%p')
         tag_mark = ' '
         taggers = set(event.interest.all())
         alts = set(self.player.get_all_characters())
         check_set = taggers.intersection(alts)
         if len(check_set):
             tag_mark = ANSIString('|C*|n')
         if self.character in taggers:
             tag_mark = ANSIString('|r*|n')
         if event.owner == self.character:
             tag_mark = ANSIString('|g*|n')
         tag_count = event.interest.all().count()
         display_string = "{}{:<2} {:<4}{:40.40}{:23.23}{:7}".format(tag_mark, tag_count, event.id, event.title,
                                                                     event.owner, time)
         message.append(display_string)
     message.append(self.player.render.footer())
     self.msg_lines(message)
Exemple #2
0
 def board_timeout_posts(self, lhs, rhs):
     boardname, postnums = lhs.split('/', 1)
     boardname.strip()
     postnums.strip()
     try:
         board_group = self.board_group
         board = board_group.find_board(find_name=boardname, checker=self.character)
         posts = board.parse_postnums(player=self.player, check=postnums)
     except ValueError as err:
         self.error(unicode(err))
         return
     if not board.timeout:
         self.error("'%s' has disabled timeouts." % board)
         return
     admin = board.perm_check(self.caller, 'admin')
     new_timeout = duration_from_string(rhs)
     if new_timeout.total_seconds() == 0 and not admin:
         self.error("Only board admins may sticky a post.")
         return
     if new_timeout > board.timeout and not admin:
         self.error("Only admin may set post timeouts above the board timeout.")
         return
     for post in posts:
         if not post.can_edit(self.player):
             self.error("Cannot Edit post '%s: %s' - Permission denied." % (post.order, post.subject))
         else:
             post.timeout = new_timeout
             post.save(update_fields=['timeout'])
             self.sys_msg("Timeout set for post '%s: %s' - now %s" % (post.order, post.subject,
                                                                      time_format(new_timeout, style=1)))
Exemple #3
0
 def do_validate(self, value, value_list):
     if not value:
         raise ValueError("%s requires a value!" % self)
     dur = duration_from_string(value)
     if not dur:
         raise ValueError('%s did not resolve into a duration.' % value)
     return int(dur)
Exemple #4
0
 def board_timeout_board_set(self, lhs, rhs):
     try:
         board_group = self.board_group
         board = board_group.find_board(find_name=lhs, group=self.group, checker=self.character)
     except ValueError as err:
         self.error(unicode(err))
         return
     if not board.perm_check(self.player, 'admin'):
         self.error("Permission denied.")
         return
     new_timeout = duration_from_string(rhs)
     timeout_string = time_format(new_timeout.total_seconds(), style=1) if new_timeout else '0 - Permanent'
     board.timeout = new_timeout
     board.save(update_fields=['timeout'])
     self.sys_msg("'%s' timeout set to: %s" % (board, timeout_string))
 def display_events(self, lhs, rhs):
     if lhs:
         self.display_event(lhs)
         return
     now = utcnow()
     interval = duration_from_string('6h')
     expired = now - interval
     events = Event.objects.filter(
         date_schedule__gte=expired).order_by('date_schedule')
     tz = self.player.settings.get('timezone')
     last_day = ''
     check_day = ''
     message = list()
     message.append(
         header("Current Schedule - %s" %
                self.caller.display_local_time(format='%Z'),
                viewer=self.caller))
     for event in events:
         check_day = self.caller.display_local_time(
             date=event.date_schedule, format='%a %b %d %Y')
         if check_day != last_day:
             message.append(subheader(check_day))
         last_day = check_day
         time = self.caller.display_local_time(date=event.date_schedule,
                                               format='%I:%M%p')
         tag_mark = ' '
         taggers = set(event.interest.all())
         alts = set(self.player.get_all_characters())
         check_set = taggers.intersection(alts)
         if len(check_set):
             tag_mark = ANSIString('|C*|n')
         if self.character in taggers:
             tag_mark = ANSIString('|r*|n')
         if event.owner == self.character:
             tag_mark = ANSIString('|g*|n')
         tag_count = event.interest.all().count()
         display_string = "{}{:<2} {:<4}{:40.40}{:23.23}{:7}".format(
             tag_mark, tag_count, event.id, event.title, event.owner, time)
         message.append(display_string)
     message.append(header(viewer=self.caller))
     self.msg_lines(message)
Exemple #6
0
        if not (enactor := session.get_account()
                ) or not enactor.check_lock("pperm(Admin)"):
            raise ValueError("Permission denied.")
        account = self.find_account(account)
        if not account.db._disabled:
            raise ValueError("Account is not disabled!")
        del account.db._disabled
        entities = {'enactor': enactor, 'account': account}
        amsg.EnableMessage(entities).send()

    def ban_account(self, session, account, duration, reason):
        if not (enactor := session.get_account()
                ) or not enactor.check_lock("pperm(Moderator)"):
            raise ValueError("Permission denied.")
        account = self.find_account(account)
        duration = duration_from_string(duration)
        ban_date = utcnow() + duration
        if not reason:
            raise ValueError("Must include a reason!")
        account.db._banned = ban_date
        account.db._ban_reason = reason
        entities = {'enactor': enactor, 'account': account}
        amsg.BanMessage(entities,
                        duration=time_format(duration.total_seconds(),
                                             style=2),
                        ban_date=ban_date.strftime('%c'),
                        reason=reason).send()
        account.force_disconnect(reason)

    def unban_account(self, session, account):
        if not (enactor := session.get_account()