diff --git a/runningmate/addproject/__pycache__/admin.cpython-39.pyc b/runningmate/addproject/__pycache__/admin.cpython-39.pyc index fc38eab..f2c6fe1 100644 Binary files a/runningmate/addproject/__pycache__/admin.cpython-39.pyc and b/runningmate/addproject/__pycache__/admin.cpython-39.pyc differ diff --git a/runningmate/addproject/__pycache__/models.cpython-310.pyc b/runningmate/addproject/__pycache__/models.cpython-310.pyc index f8ce3a5..1c471a9 100644 Binary files a/runningmate/addproject/__pycache__/models.cpython-310.pyc and b/runningmate/addproject/__pycache__/models.cpython-310.pyc differ diff --git a/runningmate/addproject/__pycache__/models.cpython-39.pyc b/runningmate/addproject/__pycache__/models.cpython-39.pyc index 96ac859..fdfa5ab 100644 Binary files a/runningmate/addproject/__pycache__/models.cpython-39.pyc and b/runningmate/addproject/__pycache__/models.cpython-39.pyc differ diff --git a/runningmate/addproject/__pycache__/views.cpython-310.pyc b/runningmate/addproject/__pycache__/views.cpython-310.pyc index 2e9acbc..d485f1e 100644 Binary files a/runningmate/addproject/__pycache__/views.cpython-310.pyc and b/runningmate/addproject/__pycache__/views.cpython-310.pyc differ diff --git a/runningmate/addproject/admin.py b/runningmate/addproject/admin.py index df4cb75..bef1703 100644 --- a/runningmate/addproject/admin.py +++ b/runningmate/addproject/admin.py @@ -6,3 +6,5 @@ @admin.register(Project) class ProjectAdmin(admin.ModelAdmin): list_display = ['id', 'startday', 'endday', 'title', 'body', 'writer', 'color'] + +admin.site.register(Follow) diff --git a/runningmate/addproject/migrations/0001_initial.py b/runningmate/addproject/migrations/0001_initial.py index 8317f15..343bada 100644 --- a/runningmate/addproject/migrations/0001_initial.py +++ b/runningmate/addproject/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.0.4 on 2022-07-10 06:52 +# Generated by Django 4.0.4 on 2022-07-10 13:50 import colorfield.fields from django.conf import settings @@ -12,14 +12,14 @@ class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('auth', '0012_alter_user_first_name_max_length'), ] operations = [ migrations.CreateModel( - name='User', + name='Follow', fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('name', models.CharField(max_length=10)), + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ], ), migrations.CreateModel( @@ -31,8 +31,22 @@ class Migration(migrations.Migration): ('title', models.CharField(max_length=200)), ('body', models.TextField(null=True)), ('color', colorfield.fields.ColorField(default='#FFFFFF', image_field=None, max_length=18, samples=[('#50cfbc', '1'), ('#fe7782', '2'), ('#45bfff', '3'), ('#ffbc54', '4'), ('#735bf2', '5')])), - ('followers', models.ManyToManyField(related_name='following', to=settings.AUTH_USER_MODEL)), + ('followers', models.ManyToManyField(related_name='following', through='addproject.Follow', to=settings.AUTH_USER_MODEL)), ('writer', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), + migrations.AddField( + model_name='follow', + name='project', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='addproject.project'), + ), + migrations.AddField( + model_name='follow', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + migrations.AlterUniqueTogether( + name='follow', + unique_together={('user', 'project')}, + ), ] diff --git a/runningmate/addproject/migrations/0002_alter_project_followers.py b/runningmate/addproject/migrations/0002_alter_project_followers.py new file mode 100644 index 0000000..5a54861 --- /dev/null +++ b/runningmate/addproject/migrations/0002_alter_project_followers.py @@ -0,0 +1,21 @@ +# Generated by Django 4.0.5 on 2022-07-10 14:23 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('auth', '0012_alter_user_first_name_max_length'), + ('addproject', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='project', + name='followers', + field=models.ManyToManyField(related_name='followers', through='addproject.Follow', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/runningmate/addproject/migrations/__pycache__/0001_initial.cpython-39.pyc b/runningmate/addproject/migrations/__pycache__/0001_initial.cpython-39.pyc index d868cc4..0f60713 100644 Binary files a/runningmate/addproject/migrations/__pycache__/0001_initial.cpython-39.pyc and b/runningmate/addproject/migrations/__pycache__/0001_initial.cpython-39.pyc differ diff --git a/runningmate/addproject/models.py b/runningmate/addproject/models.py index 94d9eac..1530279 100644 --- a/runningmate/addproject/models.py +++ b/runningmate/addproject/models.py @@ -14,23 +14,30 @@ class Project(models.Model): #프로젝트 추가 title = models.CharField(max_length=200) body = models.TextField(null=True) writer = models.ForeignKey(User,on_delete=models.CASCADE, null=True) - followers = models.ManyToManyField(User, related_name='following') - + followers = models.ManyToManyField(User, related_name='followers', through = 'Follow') + def __str__(self): return self.title def summary(self): return self.body[:30] + + @property + def followers_count(self): + return self.followers.count() + COLOR_PALETTE = [ ("#50cfbc","1",),("#fe7782","2",),("#45bfff","3",),("#ffbc54","4",),("#735bf2","5",), ] color = ColorField(samples=COLOR_PALETTE) -class User(models.Model): - id = models.AutoField(primary_key=True) - name = models.CharField(max_length=10) - +class Follow(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE) + project = models.ForeignKey(Project, on_delete=models.CASCADE) + + class Meta: + unique_together = (('user', 'project')) diff --git a/runningmate/mateapp/__pycache__/models.cpython-310.pyc b/runningmate/mateapp/__pycache__/models.cpython-310.pyc index 156860d..999ffe0 100644 Binary files a/runningmate/mateapp/__pycache__/models.cpython-310.pyc and b/runningmate/mateapp/__pycache__/models.cpython-310.pyc differ diff --git a/runningmate/mateapp/__pycache__/urls.cpython-310.pyc b/runningmate/mateapp/__pycache__/urls.cpython-310.pyc index a5faae1..c147299 100644 Binary files a/runningmate/mateapp/__pycache__/urls.cpython-310.pyc and b/runningmate/mateapp/__pycache__/urls.cpython-310.pyc differ diff --git a/runningmate/mateapp/__pycache__/views.cpython-310.pyc b/runningmate/mateapp/__pycache__/views.cpython-310.pyc index 8cb5da2..091768e 100644 Binary files a/runningmate/mateapp/__pycache__/views.cpython-310.pyc and b/runningmate/mateapp/__pycache__/views.cpython-310.pyc differ diff --git a/runningmate/mateapp/__pycache__/views.cpython-39.pyc b/runningmate/mateapp/__pycache__/views.cpython-39.pyc index e04ca71..7f21928 100644 Binary files a/runningmate/mateapp/__pycache__/views.cpython-39.pyc and b/runningmate/mateapp/__pycache__/views.cpython-39.pyc differ diff --git a/runningmate/mateapp/migrations/0001_initial.py b/runningmate/mateapp/migrations/0001_initial.py index cade670..84842db 100644 --- a/runningmate/mateapp/migrations/0001_initial.py +++ b/runningmate/mateapp/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.0.4 on 2022-07-10 06:52 +# Generated by Django 4.0.4 on 2022-07-10 13:50 import colorfield.fields from django.conf import settings @@ -11,8 +11,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('addproject', '0001_initial'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ diff --git a/runningmate/mateapp/migrations/__pycache__/0001_initial.cpython-39.pyc b/runningmate/mateapp/migrations/__pycache__/0001_initial.cpython-39.pyc index 6f06527..3c90c42 100644 Binary files a/runningmate/mateapp/migrations/__pycache__/0001_initial.cpython-39.pyc and b/runningmate/mateapp/migrations/__pycache__/0001_initial.cpython-39.pyc differ diff --git a/runningmate/mateapp/templates/mateapp/mainpage.html b/runningmate/mateapp/templates/mateapp/mainpage.html index 3c9c0d9..a610896 100644 --- a/runningmate/mateapp/templates/mateapp/mainpage.html +++ b/runningmate/mateapp/templates/mateapp/mainpage.html @@ -32,6 +32,8 @@ display: inline-block; padding-right: 10px; } + +
@@ -80,7 +82,7 @@
- {% if calendar.count == 0 %} + {% if calendar.0.title == None %}
아직 등록된 일정이 없어요
{% else %}
@@ -99,10 +101,8 @@ {% endif %}
- {% if calendar.count == 0 %} -
아직 등록된 일정이 없어요
- {% elif calendar.count == 1 %} -
아직 등록된 일정이 없어요
+ {% if calendar.1.title == None %} +
아직 등록된 일정이 없어요
{% else %}
{{calendar.1.title}}
@@ -121,13 +121,22 @@
-
러닝메이트
+
러닝메이트 + + +
+
- -
아직 등록된 러닝메이트가 없어요.
+ {% for project in projects %} + + {% for follower in project.followers.all %} + +
+ {% endfor %} - + {% endfor %}