Example #1
0
class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    image = models.ImageField(default='default.jpg', upload_to='profile_pics')
    phone = models.CharField(max_length=100, blank=True, null=True)
    id_number = models.IntegerField(blank=True, null=True)
    email = models.CharField(max_length=100, blank=True, null=True)
    facebook = models.CharField(max_length=100, blank=True, null=True)
    twitter = models.CharField(max_length=100, blank=True, null=True)
    linkedin = models.CharField(max_length=100, blank=True, null=True)
    instagram = models.CharField(max_length=100, blank=True, null=True)
    timestamp = models.DateTimeField(default=timezone.now)
    is_published = models.BooleanField(default=True)

    def __str__(self):
        return f' username--> {self.user.username} ---Fullnames--> {self.user.first_name}-{self.user.last_name} '

    def save(self, **kwargs):
        super().save()

        img = Image.open(self.image.path)

        if img.height > 300 or img.width > 300:
            output_size = (300, 300)
            img.thumbnail(output_size)
            img.save(self.image.path)
class Migration(migrations.Migration):

    dependencies = [
        ('classes', '0005_auto_20200815_1226'),
    ]

    operations = [
        migrations.AddField(
            model_name='userprofile',
            name='profile_pic',
            field=models.ImageField(
                null=True, upload_to=classes.models.user_directory_path),
        ),
    ]
class Migration(migrations.Migration):

    dependencies = [
        ('classes', '0008_auto_20200815_1709'),
    ]

    operations = [
        migrations.AlterField(
            model_name='userprofile',
            name='profile_pic',
            field=models.ImageField(
                blank=True,
                default='blank-user.jpg',
                null=True,
                upload_to=classes.models.user_directory_path),
        ),
    ]
class Migration(migrations.Migration):

    dependencies = [
        ('classes', '0011_auto_20200815_1803'),
    ]

    operations = [
        migrations.AddField(
            model_name='course',
            name='profile_pic',
            field=models.ImageField(
                blank=True,
                default='courses/blank-course.jpg',
                null=True,
                upload_to=classes.models.course_directory_path),
        ),
    ]
class Migration(migrations.Migration):

    dependencies = [
        ('classes', '0006_userprofile_profile_pic'),
    ]

    operations = [
        migrations.AlterField(
            model_name='userprofile',
            name='profile_pic',
            field=models.ImageField(
                blank=True,
                default=
                'C:\\Users\\shari\\OneDrive\\Documents\\Coding Dojo\\python_stack\\django\\django_orm\\icraft\\media\\blank-user.jpg',
                null=True,
                upload_to=classes.models.user_directory_path),
        ),
    ]
class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Account',
            fields=[
                ('account_id', models.AutoField(primary_key=True, serialize=False)),
                ('username', models.CharField(max_length=50, unique=True)),
                ('password', models.CharField(max_length=50)),
                ('first_name', models.CharField(max_length=50)),
                ('last_name', models.CharField(max_length=50)),
            ],
        ),
        migrations.CreateModel(
            name='Food',
            fields=[
                ('food_id', models.AutoField(primary_key=True, serialize=False)),
                ('food_name', models.CharField(max_length=50)),
                ('picture', models.ImageField(upload_to='uploads')),
                ('price', models.FloatField(max_length=10)),
            ],
        ),
        migrations.CreateModel(
            name='Order',
            fields=[
                ('order_id', models.AutoField(primary_key=True, serialize=False)),
                ('state', models.CharField(choices=[(classes.models.StateChoices['QUEUING'], 'Queuing'), (classes.models.StateChoices['DOING'], 'Doing'), (classes.models.StateChoices['DONE'], 'Done')], default=classes.models.StateChoices['QUEUING'], max_length=10)),
                ('total_price', models.FloatField(max_length=10)),
                ('date_time', models.DateTimeField(blank=True)),
            ],
        ),
        migrations.CreateModel(
            name='Type',
            fields=[
                ('type_id', models.AutoField(primary_key=True, serialize=False)),
                ('type_name', models.CharField(max_length=50)),
            ],
        ),
        migrations.CreateModel(
            name='Customer',
            fields=[
                ('faculty', models.CharField(max_length=50)),
                ('account_account_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='classes.Account')),
            ],
        ),
        migrations.CreateModel(
            name='Owner',
            fields=[
                ('picture_owner', models.ImageField(upload_to='uploads')),
                ('account_account_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='classes.Account')),
            ],
        ),
        migrations.CreateModel(
            name='Restaurant',
            fields=[
                ('restaurant_id', models.AutoField(primary_key=True, serialize=False)),
                ('working_hours', models.TimeField(blank=True)),
                ('picture_restaurant', models.ImageField(upload_to='uploads')),
                ('restaurant_name', models.CharField(max_length=50)),
                ('type_type_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='classes.Type')),
                ('owner_account_account_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='classes.Owner')),
            ],
        ),
        migrations.CreateModel(
            name='Order_List',
            fields=[
                ('list_no', models.AutoField(primary_key=True, serialize=False)),
                ('unit', models.IntegerField()),
                ('price', models.FloatField(max_length=50)),
                ('food_food_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='classes.Food')),
                ('order_order_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='classes.Order')),
            ],
        ),
        migrations.AddField(
            model_name='food',
            name='restaurant_restaurant_id',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='classes.Restaurant'),
        ),
        migrations.AddField(
            model_name='order',
            name='customer_account_account_id',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='classes.Customer'),
        ),
    ]
class Migration(migrations.Migration):

    dependencies = [
        ('classes', '0001_initial'),
    ]

    operations = [
        migrations.AlterField(
            model_name='account',
            name='first_name',
            field=models.CharField(blank=True, max_length=50, null=True),
        ),
        migrations.AlterField(
            model_name='account',
            name='last_name',
            field=models.CharField(blank=True, max_length=50, null=True),
        ),
        migrations.AlterField(
            model_name='account',
            name='password',
            field=models.CharField(blank=True, max_length=50, null=True),
        ),
        migrations.AlterField(
            model_name='account',
            name='username',
            field=models.CharField(blank=True,
                                   max_length=50,
                                   null=True,
                                   unique=True),
        ),
        migrations.AlterField(
            model_name='customer',
            name='account_account_id',
            field=models.OneToOneField(
                on_delete=django.db.models.deletion.CASCADE,
                primary_key=True,
                serialize=False,
                to='classes.Account'),
        ),
        migrations.AlterField(
            model_name='customer',
            name='faculty',
            field=models.CharField(blank=True, max_length=50, null=True),
        ),
        migrations.AlterField(
            model_name='food',
            name='food_name',
            field=models.CharField(blank=True, max_length=50, null=True),
        ),
        migrations.AlterField(
            model_name='food',
            name='picture',
            field=models.ImageField(blank=True, null=True,
                                    upload_to='uploads'),
        ),
        migrations.AlterField(
            model_name='food',
            name='price',
            field=models.FloatField(blank=True, max_length=10, null=True),
        ),
        migrations.AlterField(
            model_name='food',
            name='restaurant_restaurant_id',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='classes.Restaurant'),
        ),
        migrations.AlterField(
            model_name='order',
            name='customer_account_account_id',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='classes.Customer'),
        ),
        migrations.AlterField(
            model_name='order',
            name='date_time',
            field=models.DateTimeField(auto_now_add=True),
        ),
        migrations.AlterField(
            model_name='order',
            name='state',
            field=models.CharField(
                blank=True,
                choices=[(classes.models.StateChoices['QUEUING'], 'Queuing'),
                         (classes.models.StateChoices['DOING'], 'Doing'),
                         (classes.models.StateChoices['DONE'], 'Done')],
                default=classes.models.StateChoices['QUEUING'],
                max_length=10,
                null=True),
        ),
        migrations.AlterField(
            model_name='order',
            name='total_price',
            field=models.FloatField(blank=True, max_length=10, null=True),
        ),
        migrations.AlterField(
            model_name='order_list',
            name='food_food_id',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='classes.Food'),
        ),
        migrations.AlterField(
            model_name='order_list',
            name='order_order_id',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='classes.Order'),
        ),
        migrations.AlterField(
            model_name='order_list',
            name='price',
            field=models.FloatField(blank=True, max_length=50, null=True),
        ),
        migrations.AlterField(
            model_name='order_list',
            name='unit',
            field=models.IntegerField(blank=True, null=True),
        ),
        migrations.AlterField(
            model_name='owner',
            name='account_account_id',
            field=models.OneToOneField(
                on_delete=django.db.models.deletion.CASCADE,
                primary_key=True,
                serialize=False,
                to='classes.Account'),
        ),
        migrations.AlterField(
            model_name='owner',
            name='picture_owner',
            field=models.ImageField(blank=True, null=True,
                                    upload_to='uploads'),
        ),
        migrations.AlterField(
            model_name='restaurant',
            name='owner_account_account_id',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='classes.Owner'),
        ),
        migrations.AlterField(
            model_name='restaurant',
            name='picture_restaurant',
            field=models.ImageField(blank=True, null=True,
                                    upload_to='uploads'),
        ),
        migrations.AlterField(
            model_name='restaurant',
            name='restaurant_name',
            field=models.CharField(blank=True, max_length=50, null=True),
        ),
        migrations.AlterField(
            model_name='restaurant',
            name='type_type_id',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='classes.Type'),
        ),
        migrations.AlterField(
            model_name='restaurant',
            name='working_hours',
            field=models.TimeField(blank=True, null=True),
        ),
    ]
Example #8
0
class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('classes', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Lessons',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('lesson_id', models.CharField(max_length=100, unique=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('name', models.CharField(max_length=250)),
                ('position',
                 models.PositiveSmallIntegerField(
                     verbose_name='Lecture Number')),
                ('slug', models.SlugField(blank=True, null=True)),
                ('video',
                 models.FileField(blank=True,
                                  null=True,
                                  upload_to=classes.models.lesson_files,
                                  verbose_name='Video')),
                ('notes',
                 models.FileField(blank=True,
                                  null=True,
                                  upload_to=classes.models.lesson_files,
                                  verbose_name='Notes')),
                ('ppt',
                 models.FileField(blank=True,
                                  null=True,
                                  upload_to=classes.models.lesson_files,
                                  verbose_name='Presentation')),
            ],
            options={
                'ordering': ['position'],
            },
        ),
        migrations.CreateModel(
            name='Semester',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=100, unique=True)),
                ('slug', models.SlugField(blank=True, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Subjects',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('subject_id', models.CharField(max_length=100, unique=True)),
                ('name', models.CharField(max_length=100)),
                ('slug', models.SlugField(blank=True, null=True)),
                ('image',
                 models.ImageField(blank=True,
                                   upload_to=classes.models.subject_image,
                                   verbose_name='Subject Image')),
            ],
        ),
        migrations.RemoveField(
            model_name='subject',
            name='branch',
        ),
        migrations.RemoveField(
            model_name='subject',
            name='year',
        ),
        migrations.RemoveField(
            model_name='year',
            name='branch',
        ),
        migrations.RemoveField(
            model_name='branch',
            name='description',
        ),
        migrations.DeleteModel(name='Lesson', ),
        migrations.DeleteModel(name='Subject', ),
        migrations.DeleteModel(name='Year', ),
        migrations.AddField(
            model_name='subjects',
            name='branch',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='classes.Branch'),
        ),
        migrations.AddField(
            model_name='subjects',
            name='semester',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='subjects',
                to='classes.Semester'),
        ),
        migrations.AddField(
            model_name='semester',
            name='branch',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='semester',
                to='classes.Branch'),
        ),
        migrations.AddField(
            model_name='lessons',
            name='branch',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='classes.Branch'),
        ),
        migrations.AddField(
            model_name='lessons',
            name='created_by',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='lessons',
            name='semester',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='classes.Semester'),
        ),
        migrations.AddField(
            model_name='lessons',
            name='subjects',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='lessons',
                to='classes.Subjects'),
        ),
    ]
Example #9
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Image',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('image_file',
                 models.ImageField(blank=True,
                                   null=True,
                                   upload_to=classes.models.get_image_fk)),
                ('created_at',
                 models.DateTimeField(auto_now_add=True, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Membership',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
            ],
        ),
        migrations.CreateModel(
            name='Opinion',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('content', models.TextField()),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
        ),
        migrations.CreateModel(
            name='TheClass',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('class_name',
                 models.CharField(blank=True, max_length=120, null=True)),
                ('start_at', models.DateTimeField(blank=True, null=True)),
                ('available',
                 models.CharField(blank=True, max_length=50, null=True)),
                ('is_done',
                 models.BooleanField(blank=True, default=False, null=True)),
                ('created_at',
                 models.DateTimeField(auto_now_add=True, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Video',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('video_file',
                 models.FileField(blank=True,
                                  null=True,
                                  upload_to=classes.models.get_video_fk)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('belongs_to',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='videos',
                                   to='classes.TheClass')),
            ],
        ),
    ]