コード例 #1
0
ファイル: models.py プロジェクト: Hyyudu/Cetaganda
    def change_owner(self, owner):
        alliance = Alliance.get_alliance(owner)
        self.alliance = alliance
        self.owner = owner
        self.save()

    def destroy(self):
        self.is_alive = False
        self.save()

        if not self.fleet.ship_set.filter(is_alive=True).exists():
            self.fleet.delete()


Goods.register(Ship)


class Picture(models.Model):
    requester = models.ForeignKey(Role, verbose_name='Заказчик')
    point = models.ForeignKey(Point, verbose_name='Откуда')
    direction = models.CharField(verbose_name='Направление', max_length=255)
    photo = YFField(upload_to='cetaganda', null=True, default=None)
    dt = models.DateTimeField(verbose_name='Время', auto_now=True)

    class Meta:
        verbose_name = 'Снимок'
        verbose_name_plural = 'Снимки'


class Report(models.Model):
コード例 #2
0
ファイル: models.py プロジェクト: Hyyudu/Cetaganda
    def market_name(self):
        return 'Поплавок'

    def market_description(self):
        return ''

    def change_owner(self, owner):
        self.owner = owner
        self.save()

    class Meta:
        verbose_name = 'Поплавок'
        verbose_name_plural = 'Поплавки'


Goods.register(Float)


class Hack(models.Model):
    """Хак без защитника"""
    hacker = models.ForeignKey(Role, verbose_name='Хакер')
    hash = models.CharField(verbose_name='Хэш', max_length=32)
    target = models.ForeignKey(Target, verbose_name='Цель')
    dt = models.DateTimeField(auto_now_add=True, verbose_name='Начало атаки')
    number = models.CharField(max_length=10, verbose_name='Взламываемое число')
    STATUSES = (
        (None, 'Создано'),
        ('inprocess', 'Идет'),
        ('win', 'Взломано'),
        ('run', 'Сбежал'),
        ('failstatic', 'Не хватило поплавков'),