Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/accounts/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from .models import Profile, CustomUser
from .models import Profile, CustomUser, SocialMediaType

admin.site.register(Profile)
admin.site.register(CustomUser)
admin.site.register(SocialMediaType)
19 changes: 19 additions & 0 deletions api/accounts/migrations/0015_profile_groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.0.8 on 2020-07-06 13:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('community', '0006_media_author'),
('accounts', '0014_merge_20200518_2025'),
]

operations = [
migrations.AddField(
model_name='profile',
name='groups',
field=models.ManyToManyField(blank=True, null=True, related_name='gropus', to='community.Group'),
),
]
19 changes: 19 additions & 0 deletions api/accounts/migrations/0016_auto_20200706_1422.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.0.8 on 2020-07-06 14:22

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('community', '0006_media_author'),
('accounts', '0015_profile_groups'),
]

operations = [
migrations.AlterField(
model_name='profile',
name='groups',
field=models.ManyToManyField(blank=True, null=True, related_name='groups', to='community.Group'),
),
]
7 changes: 6 additions & 1 deletion api/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.contrib.auth.models import AbstractUser
from django.apps import apps
from .managers import CustomUserManager
from community.models import Group


class CustomUser(AbstractUser):
Expand Down Expand Up @@ -30,7 +31,8 @@ class Profile(models.Model):
last_name = models.CharField(max_length=200, null=True)
#cities_of_residence = models.ManyToManyField('trip.Location', related_name='people',null=True, blank=True)
# city_of_residence = models.CharField(max_length=200)
city_of_residence = models.ForeignKey('trip.Location', on_delete=models.CASCADE, related_name='people', null=True, blank=True)
city_of_residence = models.ForeignKey(
'trip.Location', on_delete=models.CASCADE, related_name='people', null=True, blank=True)
age = models.IntegerField(null=True)
dream_destination = models.CharField(max_length=200, blank=True)
bio = models.TextField(blank=True)
Expand All @@ -40,8 +42,11 @@ class Profile(models.Model):
'community.Event', related_name='people', null=True, blank=True)
connections = models.ManyToManyField(
'self', related_name='friends', null=True, blank=True)

# Posts, comments, and replies to be defined as foreign key on those respective models within forum app
# CoTrip media defined as foreign key in community app
groups = models.ManyToManyField(
Group, related_name='members', null=True, blank=True)

def __str__(self):
return f'{self.first_name} {self.last_name} Profile'
Expand Down
2 changes: 1 addition & 1 deletion api/accounts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ProfileSerializer(serializers.ModelSerializer):
class Meta:
model = Profile
fields = ['user', 'topics', 'hashtags', 'image', 'first_name', 'last_name', 'city_of_residence',
'age', 'dream_destination', 'bio', 'activities', 'events', 'connections', 'social_media']
'age', 'dream_destination', 'bio', 'activities', 'events', 'connections', 'social_media', 'groups']


class UserSerializer(serializers.ModelSerializer):
Expand Down
12 changes: 9 additions & 3 deletions api/community/fixtures/community.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@
"model": "community.group",
"pk": 1,
"fields": {
"id": 0,
"title": "Moms in DC",
"description": "Ladies others the six desire age. Bred am soon park past read by lain. As excuse eldest no moment. An delight beloved up garrets am cottage private."
"description": "Ladies others the six desire age. Bred am soon park past read by lain. As excuse eldest no moment. An delight beloved up garrets am cottage private.",
"location": 60
}
},
{
"model": "community.group",
"pk": 2,
"fields": {
"id": 1,
"title": "Moms in NYC",
"description": "Ladies others the six desire age. Bred am soon park past read by lain. As excuse eldest no moment. An delight beloved up garrets am cottage private."
"description": "Ladies others the six desire age. Bred am soon park past read by lain. As excuse eldest no moment. An delight beloved up garrets am cottage private.",
"location": 3658
}
},
{
"model": "community.group",
"pk": 3,
"fields": {
"id": 2,
"title": "Moms in Philadelphia",
"description": "Ladies others the six desire age. Bred am soon park past read by lain. As excuse eldest no moment. An delight beloved up garrets am cottage private."
"description": "Ladies others the six desire age. Bred am soon park past read by lain. As excuse eldest no moment. An delight beloved up garrets am cottage private.",
"location": 4168
}
},
{
Expand Down
20 changes: 20 additions & 0 deletions api/community/migrations/0007_group_location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.0.8 on 2020-07-06 15:48

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('trip', '0015_remove_location_groups'),
('community', '0006_media_author'),
]

operations = [
migrations.AddField(
model_name='group',
name='location',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='group', to='trip.Location'),
),
]
10 changes: 6 additions & 4 deletions api/community/models.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from django.db import models
from trip.models import Location

# Create your models here.


class Group(models.Model):
# Location defined in trip.models
title = models.CharField(max_length=200)
description = models.CharField(max_length=500, blank=True, null=True)
# Members defined in account.models in Profile model
# Posts: one to many with post model
location = models.ForeignKey(
Location, on_delete=models.CASCADE, related_name='group', null=True, blank=True)
# Members defined in account.models in Profile model
# Posts: one to many with post model
# (should be) taken care of in the Post model

def __str__(self):
Expand Down Expand Up @@ -46,7 +48,7 @@ class Hashtag(models.Model):

def __str__(self):
return self.title


class Media(models.Model):
# title and file are required. hashtags, topics, and groups are optional
Expand Down
2 changes: 1 addition & 1 deletion api/community/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class GroupSerializer(serializers.ModelSerializer):
class Meta:
model = Group
fields = '__all__'
fields = ['title', 'description', 'location', 'posts', 'members']

class EventSerializer(serializers.ModelSerializer):
group = serializers.CharField()
Expand Down
65 changes: 50 additions & 15 deletions api/forum/fixtures/forum.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"body": "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit",
"likes": 0,
"author": 1,
"parent": []
"parent": [],
"group": 1
}
},
{
Expand All @@ -22,7 +23,8 @@
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
"likes": 0,
"author": 2,
"parent": []
"parent": [],
"group": 1
}
},
{
Expand All @@ -35,7 +37,8 @@
"body": "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"likes": 0,
"author": 3,
"parent": []
"parent": [],
"group": 1
}
},
{
Expand All @@ -48,7 +51,8 @@
"body": "Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.",
"likes": 0,
"author": 5,
"parent": []
"parent": [],
"group": 2
}
},
{
Expand All @@ -61,7 +65,8 @@
"body": "Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.",
"likes": 0,
"author": 4,
"parent": []
"parent": [],
"group": 2
}
},
{
Expand All @@ -74,7 +79,10 @@
"body": "Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? ",
"likes": 0,
"author": 1,
"parent": [1]
"parent": [
1
],
"group": 2
}
},
{
Expand All @@ -87,7 +95,10 @@
"body": "Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?",
"likes": 0,
"author": 2,
"parent": [2]
"parent": [
2
],
"group": 2
}
},
{
Expand All @@ -100,7 +111,10 @@
"body": "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum.",
"likes": 0,
"author": 3,
"parent": [3]
"parent": [
3
],
"group": 2
}
},
{
Expand All @@ -113,7 +127,10 @@
"body": "Deleniti atque corrupti quos dolores et quas molestias excepturi sint.",
"likes": 0,
"author": 4,
"parent": [4]
"parent": [
4
],
"group": 2
}
},
{
Expand All @@ -126,7 +143,10 @@
"body": "Occaecati cupiditate non provident, similique sunt in culpa qui officia.",
"likes": 0,
"author": 1,
"parent": [5]
"parent": [
5
],
"group": 3
}
},
{
Expand All @@ -139,7 +159,10 @@
"body": "Deserunt mollitia animi, id est laborum et dolorum fuga.",
"likes": 0,
"author": 1,
"parent": [6]
"parent": [
6
],
"group": 3
}
},
{
Expand All @@ -152,7 +175,10 @@
"body": "Et harum quidem rerum facilis est et expedita distinctio.",
"likes": 0,
"author": 2,
"parent": [7]
"parent": [
7
],
"group": 3
}
},
{
Expand All @@ -165,7 +191,10 @@
"body": "Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus.",
"likes": 0,
"author": 3,
"parent": [8]
"parent": [
8
],
"group": 3
}
},
{
Expand All @@ -178,7 +207,10 @@
"body": "Omnis voluptas assumenda est, omnis dolor repellendus.",
"likes": 0,
"author": 4,
"parent": [9]
"parent": [
9
],
"group": 3
}
},
{
Expand All @@ -191,7 +223,10 @@
"body": "Temporibus autem quibusdam et aut officiis debitis aut rerum.",
"likes": 0,
"author": 5,
"parent": [10]
"parent": [
10
],
"group": 3
}
}
]
20 changes: 20 additions & 0 deletions api/forum/migrations/0005_post_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.0.8 on 2020-07-06 14:22

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('community', '0006_media_author'),
('forum', '0004_auto_20200409_1801'),
]

operations = [
migrations.AddField(
model_name='post',
name='group',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='posts', to='community.Group'),
),
]
6 changes: 5 additions & 1 deletion api/forum/models.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from django.db import models
from accounts.models import Profile
from community.models import Group


class Post(models.Model):
parent = models.ManyToManyField('self', related_name='comments', null=True, blank=True)
parent = models.ManyToManyField(
'self', related_name='comments', null=True, blank=True)
post_type = models.CharField(max_length=200, null=True, blank=True)
title = models.CharField(max_length=200)
time = models.DateTimeField(auto_now=True)
body = models.CharField(max_length=1000)
likes = models.IntegerField(default=0)
author = models.ForeignKey(Profile,
on_delete=models.CASCADE, related_name='posts', null=True)
group = models.ForeignKey(
Group, on_delete=models.CASCADE, related_name='posts', null=True)

def __str__(self):
return self.title
Loading