Exemple #1
0
class ProjectProces(Source):
    phase = models.CharField(max_length=255)
    startDate = models.DateTimeField()
    endDate = models.DateTimeField()

    def __str__(self):
        return 'ProjectProces: ' + self.phase + '.' + self.subject
Exemple #2
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='User',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('password',
                 models.CharField(max_length=128, verbose_name='password')),
                ('last_login',
                 models.DateTimeField(blank=True,
                                      null=True,
                                      verbose_name='last login')),
                ('contact_number',
                 models.CharField(
                     max_length=10,
                     unique=True,
                     validators=[users.models.validate_contact_number],
                     verbose_name='Contact Number')),
                ('is_staff', models.BooleanField(default=False)),
                ('is_superuser', models.BooleanField(default=False)),
            ],
            options={
                'abstract': False,
            },
        ),
    ]
Exemple #3
0
class Knowledge(models.Model):
    subject = models.CharField(max_length=255)
    source = models.ForeignKey('Source', related_name='knowledge')
    author = models.ForeignKey('users.KUser', related_name='knowledge')
    summary = models.CharField(max_length=255, blank=True, null=True)
    gainWay = models.TextField(blank=True, null=True)
    access = models.IntegerField(default=0)
    createDate = models.DateTimeField(default=datetime.now)

    content = models.TextField(blank=True, null=True)
    file = models.FileField(blank=True,
                            null=True,
                            upload_to=knowledge_file_name)

    def __str__(self):
        return '' + self.subject

    def presentation(self):
        return self.subject

    def rate(self, kuser, vote):
        try:
            rate = Rate.objects.get(knowledge=self, voter=kuser)
        except:
            rate = Rate()
            rate.knowledge = self
            rate.voter = kuser
        rate.up = vote
        rate.save()

    @staticmethod
    def kdelete(id):
        print('remove knowledge :' + repr(id))
        Knowledge.objects.filter(pk=id).delete()
class RoadQuery(models.Model):
    RoadQueryID = models.AutoField(primary_key=True)
    RoadQueryName = models.CharField(max_length=50)
    RoadQueryAddress = models.CharField(max_length=50)
    RoadQueryPicture = models.CharField(max_length=100, blank=True)
    Classify = models.ManyToManyField(Classify)
    Introduction = models.TextField()
    Star = models.IntegerField(default=0)
    OpenTime = models.CharField(max_length=50)
    Latitude = models.CharField(max_length=30)
    Longitude = models.CharField(max_length=30)
    CreateUser = models.ForeignKey(UserAccount, on_delete=models.PROTECT, related_name='RoadQuery_CreateUser')
    CreateDate = models.DateTimeField()
    ModifyDate = models.DateTimeField()

    def __str__(self):
        return self.RoadQueryName
Exemple #5
0
class Comment(models.Model):
    author = models.ForeignKey('users.KUser', related_name='comments')
    knowledge = models.ForeignKey('Knowledge', related_name='comments')
    text = models.TextField()
    date = models.DateTimeField(default=datetime.now)

    def __str__(self):
        return 'comment: ' + self.author.user.username + ' on ' + self.knowledge.subject
Exemple #6
0
class UserFavorite(models.Model):
    """用户收藏模型"""
    user = models.ForeignKey(UserProfile, verbose_name='用户')
    fav_id = models.IntegerField(default=0, verbose_name='数据id')
    fav_type = models.CharField(choices=(('topic', 'topic'), ('node', 'node'),
                                         ('user', 'user')),
                                max_length=10,
                                verbose_name='收藏类型')
    add_time = models.DateTimeField(default=datetime.now, verbose_name='添加时间')
Exemple #7
0
class Source(models.Model):
    subject = models.CharField(max_length=255, unique=True)
    description = models.TextField()
    createDate = models.DateTimeField(default=datetime.now)

    def __str__(self):
        return self.subject

    def presentation(self):
        return self.subject
Exemple #8
0
class Cards(models.Model):
    ticket_cost = models.PositiveIntegerField(default=11)
    winner_prize = models.PositiveIntegerField(default=100)
    is_result_generated = models.BooleanField(default=False)
    created = models.DateTimeField(auto_now_add=True)
Exemple #9
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('auth', '0011_update_proxy_permissions'),
    ]

    operations = [
        migrations.CreateModel(
            name='User',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('password',
                 models.CharField(max_length=128, verbose_name='password')),
                ('last_login',
                 models.DateTimeField(blank=True,
                                      null=True,
                                      verbose_name='last login')),
                (
                    'is_superuser',
                    models.BooleanField(
                        default=False,
                        help_text=
                        'Designates that this user has all permissions without explicitly assigning them.',
                        verbose_name='superuser status',
                    ),
                ),
                ('first_name',
                 models.CharField(blank=True,
                                  max_length=30,
                                  verbose_name='first name')),
                ('last_name',
                 models.CharField(blank=True,
                                  max_length=150,
                                  verbose_name='last name')),
                (
                    'is_staff',
                    models.BooleanField(
                        default=False,
                        help_text=
                        'Designates whether the user can log into this admin site.',
                        verbose_name='staff status',
                    ),
                ),
                (
                    'is_active',
                    models.BooleanField(
                        default=True,
                        help_text=
                        'Designates whether this user should be treated as active. Unselect this instead of deleting accounts.',
                        verbose_name='active',
                    ),
                ),
                ('date_joined',
                 models.DateTimeField(default=django.utils.timezone.now,
                                      verbose_name='date joined')),
                ('email',
                 models.EmailField(max_length=254,
                                   unique=True,
                                   verbose_name='email address')),
                (
                    'groups',
                    models.ManyToManyField(
                        blank=True,
                        help_text=
                        'The groups this user belongs to. A user will get all permissions granted to each of their groups.',
                        related_name='user_set',
                        related_query_name='user',
                        to='auth.Group',
                        verbose_name='groups',
                    ),
                ),
                (
                    'user_permissions',
                    models.ManyToManyField(
                        blank=True,
                        help_text='Specific permissions for this user.',
                        related_name='user_set',
                        related_query_name='user',
                        to='auth.Permission',
                        verbose_name='user permissions',
                    ),
                ),
            ],
            options={
                'verbose_name': 'user',
                'verbose_name_plural': 'users',
                'abstract': False
            },
            managers=[('objects', users.models.UserManager())],
        ),
    ]
Exemple #10
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('auth', '0012_alter_user_first_name_max_length'),
    ]

    operations = [
        migrations.CreateModel(
            name='User',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('password',
                 models.CharField(max_length=128, verbose_name='password')),
                ('last_login',
                 models.DateTimeField(blank=True,
                                      null=True,
                                      verbose_name='last login')),
                ('date_joined',
                 models.DateTimeField(default=django.utils.timezone.now,
                                      verbose_name='date joined')),
                ('first_name', models.CharField(max_length=100)),
                ('last_name', models.CharField(max_length=100)),
                ('username', models.CharField(max_length=100)),
                ('email',
                 models.EmailField(max_length=254,
                                   unique=True,
                                   verbose_name='email')),
                ('country',
                 django_countries.fields.CountryField(blank=True,
                                                      max_length=2,
                                                      null=True)),
                ('profile_picutre',
                 models.ImageField(blank=True,
                                   default='users_images/default_avatar.png',
                                   null=True,
                                   upload_to='users_images/')),
                ('phone_number',
                 models.CharField(
                     blank=True,
                     max_length=16,
                     null=True,
                     validators=[
                         django.core.validators.RegexValidator(
                             message=
                             'Phone number must be entered in the egyption format',
                             regex='(01)[0-9]{9}$')
                     ])),
                ('birth_date', models.DateField(null=True)),
                ('is_admin', models.BooleanField(default=False)),
                ('is_superuser', models.BooleanField(default=False)),
                ('is_staff', models.BooleanField(default=False)),
                ('is_active', models.BooleanField(default=False)),
                ('groups',
                 models.ManyToManyField(
                     blank=True,
                     help_text=
                     'The groups this user belongs to. A user will get all permissions granted to each of their groups.',
                     related_name='user_set',
                     related_query_name='user',
                     to='auth.Group',
                     verbose_name='groups')),
                ('user_permissions',
                 models.ManyToManyField(
                     blank=True,
                     help_text='Specific permissions for this user.',
                     related_name='user_set',
                     related_query_name='user',
                     to='auth.Permission',
                     verbose_name='user permissions')),
            ],
            options={
                'verbose_name': 'user',
                'verbose_name_plural': 'users',
                'abstract': False,
            },
            managers=[
                ('objects', users.models.UserAccountManager()),
            ],
        ),
    ]