Skip to content

Commit

Permalink
Merge 01d9034 into 4da5c6c
Browse files Browse the repository at this point in the history
  • Loading branch information
Benkimeric committed May 20, 2019
2 parents 4da5c6c + 01d9034 commit 90ab468
Show file tree
Hide file tree
Showing 19 changed files with 180 additions and 54 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ The preferred JSON object to be returned by the API should be structured as foll
"title": "How to train your dragon",
"description": "Ever wonder how?",
"body": "It takes a Jacobian",
"tagList": ["dragons", "training"],
"createdAt": "2016-02-18T03:22:56.637Z",
"updatedAt": "2016-02-18T03:48:35.824Z",
"tag_list": ["dragons", "training"],
"created_at": "2016-02-18T03:22:56.637Z",
"updated_at": "2016-02-18T03:48:35.824Z",
"favorited": false,
"favoritesCount": 0,
"favorites_count": 0,
"author": {
"username": "jake",
"bio": "I work at statefarm",
Expand All @@ -70,11 +70,11 @@ The preferred JSON object to be returned by the API should be structured as foll
"title": "How to train your dragon",
"description": "Ever wonder how?",
"body": "It takes a Jacobian",
"tagList": ["dragons", "training"],
"createdAt": "2016-02-18T03:22:56.637Z",
"updatedAt": "2016-02-18T03:48:35.824Z",
"tag_list": ["dragons", "training"],
"created_at": "2016-02-18T03:22:56.637Z",
"updated_at": "2016-02-18T03:48:35.824Z",
"favorited": false,
"favoritesCount": 0,
"favorites_count": 0,
"author": {
"username": "jake",
"bio": "I work at statefarm",
Expand All @@ -87,28 +87,28 @@ The preferred JSON object to be returned by the API should be structured as foll
"title": "How to train your dragon 2",
"description": "So toothless",
"body": "It a dragon",
"tagList": ["dragons", "training"],
"createdAt": "2016-02-18T03:22:56.637Z",
"updatedAt": "2016-02-18T03:48:35.824Z",
"tag_list": ["dragons", "training"],
"created_at": "2016-02-18T03:22:56.637Z",
"updated_at": "2016-02-18T03:48:35.824Z",
"favorited": false,
"favoritesCount": 0,
"favorites_count": 0,
"author": {
"username": "jake",
"bio": "I work at statefarm",
"image": "https://i.stack.imgur.com/xHWG8.jpg",
"following": false
}
}],
"articlesCount": 2
"articles_count": 2
}
```
### Single Comment
```source-json
{
"comment": {
"id": 1,
"createdAt": "2016-02-18T03:22:56.637Z",
"updatedAt": "2016-02-18T03:22:56.637Z",
"created_at": "2016-02-18T03:22:56.637Z",
"updated_at": "2016-02-18T03:22:56.637Z",
"body": "It takes a Jacobian",
"author": {
"username": "jake",
Expand All @@ -124,8 +124,8 @@ The preferred JSON object to be returned by the API should be structured as foll
{
"comments": [{
"id": 1,
"createdAt": "2016-02-18T03:22:56.637Z",
"updatedAt": "2016-02-18T03:22:56.637Z",
"created_at": "2016-02-18T03:22:56.637Z",
"updated_at": "2016-02-18T03:22:56.637Z",
"body": "It takes a Jacobian",
"author": {
"username": "jake",
Expand All @@ -134,7 +134,7 @@ The preferred JSON object to be returned by the API should be structured as foll
"following": false
}
}],
"commentsCount": 1
"comments_count": 1
}
```
### List of Tags
Expand Down Expand Up @@ -312,7 +312,7 @@ Example request body:
"title": "How to train your dragon",
"description": "Ever wonder how?",
"body": "You have to believe",
"tagList": ["reactjs", "angularjs", "dragons"]
"tag_list": ["reactjs", "angularjs", "dragons"]
}
}
```
Expand All @@ -321,7 +321,7 @@ Authentication required, will return an Article

Required fields: `title``description``body`

Optional fields: `tagList` as an array of Strings
Optional fields: `tag_list` as an array of Strings

### Update Article

Expand Down
32 changes: 32 additions & 0 deletions authors/apps/articles/migrations/0034_auto_20190517_1220.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 2.2 on 2019-05-17 12:20

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('articles', '0033_merge_20190516_1307'),
]

operations = [
migrations.AlterModelOptions(
name='articlemodel',
options={'ordering': ['-created_at']},
),
migrations.RenameField(
model_name='articlemodel',
old_name='createdAt',
new_name='created_at',
),
migrations.RenameField(
model_name='articlemodel',
old_name='tagList',
new_name='tag_list',
),
migrations.RenameField(
model_name='articlemodel',
old_name='updatedAt',
new_name='updated_at',
),
]
18 changes: 18 additions & 0 deletions authors/apps/articles/migrations/0035_auto_20190520_0945.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2 on 2019-05-20 09:45

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('articles', '0034_auto_20190517_1220'),
]

operations = [
migrations.RenameField(
model_name='articlemodel',
old_name='favoritesCount',
new_name='favorites_count',
),
]
10 changes: 5 additions & 5 deletions authors/apps/articles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class ArticleModel(VoteModel, models.Model):
title = models.CharField(max_length=254)
description = models.TextField(blank=False, null=False)
body = models.TextField(blank=False, null=False)
tagList = models.ManyToManyField(TagModel)
createdAt = models.DateTimeField(auto_now_add=True, editable=False)
updatedAt = models.DateTimeField(auto_now_add=True, editable=True)
tag_list = models.ManyToManyField(TagModel)
created_at = models.DateTimeField(auto_now_add=True, editable=False)
updated_at = models.DateTimeField(auto_now_add=True, editable=True)
favorited = models.BooleanField(default=False)
favoritesCount = models.IntegerField(default=0)
favorites_count = models.IntegerField(default=0)
image = models.TextField(max_length=1000, validators=[
URLValidator], null=False, default='')
num_vote_down = models.IntegerField(default=0)
Expand All @@ -55,7 +55,7 @@ def __str__(self):
return "{}".format(self.title) # pragma: no cover

class Meta:
ordering = ["-createdAt"]
ordering = ["-created_at"]


class FavoriteArticleModel(models.Model):
Expand Down
14 changes: 7 additions & 7 deletions authors/apps/articles/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ class ArticleSerializer(serializers.ModelSerializer):
"""The article serializer."""
comments = serializers.SerializerMethodField()
favorited = serializers.SerializerMethodField()
favoritesCount = serializers.SerializerMethodField()
favorites_count = serializers.SerializerMethodField()
highlights = serializers.SerializerMethodField()

average_rating = serializers.SerializerMethodField(
method_name='rating',
read_only=True)

tagList = TagField(
tag_list = TagField(
many=True,
required=False
)
Expand All @@ -78,11 +78,11 @@ class Meta:
'title',
'description',
'body',
'tagList',
'createdAt',
'updatedAt',
'tag_list',
'created_at',
'updated_at',
'favorited',
'favoritesCount',
'favorites_count',
'average_rating',
'author',
'image',
Expand Down Expand Up @@ -130,7 +130,7 @@ def check_anonymous(self):
if request:
return False

def get_favoritesCount(self, obj):
def get_favorites_count(self, obj):

favorited_articles = FavoriteArticleModel.objects.all().filter(
article=obj).count()
Expand Down
6 changes: 3 additions & 3 deletions authors/apps/articles/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class ArticleFilter(FilterSet):
lookup_expr='icontains')
author = rest_framework.CharFilter('author__username',
lookup_expr='icontains')
tag = rest_framework.CharFilter('tagList',
tag = rest_framework.CharFilter('tag_list',
lookup_expr='iexact',
method='m2mfilter')

Expand All @@ -141,14 +141,14 @@ class Meta:

def m2mfilter(self, qs, tags, value):
"""
Custom filter for the manytomany tagList field
Custom filter for the manytomany tag_list field
"""

if not value:
return qs

values = value.split(',')
return qs.filter(tagList__tagname__in=values).distinct()
return qs.filter(tag_list__tagname__in=values).distinct()


class TagField(serializers.RelatedField):
Expand Down
2 changes: 1 addition & 1 deletion authors/apps/articles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def list(self, request, *args, **kwargs):
data = configure_response(serializer)
return Response(
{"Comments": data,
"commentsCount": queryset.count()})
"comments_count": queryset.count()})


class CommentLikeView(GenericAPIView):
Expand Down
22 changes: 22 additions & 0 deletions authors/apps/notifications/migrations/0006_auto_20190517_1220.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 2.2 on 2019-05-17 12:20

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('notifications', '0005_auto_20190509_0353'),
]

operations = [
migrations.AlterModelOptions(
name='notifications',
options={'ordering': ['-created_at']},
),
migrations.RenameField(
model_name='notifications',
old_name='createdAt',
new_name='created_at',
),
]
14 changes: 14 additions & 0 deletions authors/apps/notifications/migrations/0007_merge_20190520_1150.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.2 on 2019-05-20 11:50

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('notifications', '0006_auto_20190520_0901'),
('notifications', '0006_auto_20190517_1220'),
]

operations = [
]
4 changes: 2 additions & 2 deletions authors/apps/notifications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class Notifications(models.Model):

read = models.BooleanField(default=False)

createdAt = models.DateTimeField(auto_now_add=True, editable=False)
created_at = models.DateTimeField(auto_now_add=True, editable=False)

class Meta:
ordering = ["-createdAt"]
ordering = ["-created_at"]

def __str__(self):

Expand Down
4 changes: 2 additions & 2 deletions authors/apps/notifications/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class NotificationSerializer(serializers.ModelSerializer):
of Notification objects
"""

createdAt = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")
created_at = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")

class Meta:
model = Notifications

fields = ("url", "message", "createdAt", "id", "read")
fields = ("url", "message", "created_at", "id", "read")

def update(self, instance, validated_data):

Expand Down
22 changes: 22 additions & 0 deletions authors/apps/reports/migrations/0009_auto_20190517_1220.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 2.2 on 2019-05-17 12:20

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('reports', '0008_remove_reportmodel_reporter'),
]

operations = [
migrations.AlterModelOptions(
name='reportmodel',
options={'ordering': ['-created_at']},
),
migrations.RenameField(
model_name='reportmodel',
old_name='createdAt',
new_name='created_at',
),
]
18 changes: 18 additions & 0 deletions authors/apps/reports/migrations/0010_auto_20190520_0951.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2 on 2019-05-20 09:51

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('reports', '0009_auto_20190517_1220'),
]

operations = [
migrations.RenameField(
model_name='reportmodel',
old_name='updatedAt',
new_name='updated_at',
),
]
6 changes: 3 additions & 3 deletions authors/apps/reports/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class ReportModel(models.Model):
)

reason = models.TextField(max_length=700)
createdAt = models.DateTimeField(auto_now_add=True, editable=False)
updatedAt = models.DateTimeField(auto_now_add=True, editable=True)
created_at = models.DateTimeField(auto_now_add=True, editable=False)
updated_at = models.DateTimeField(auto_now_add=True, editable=True)

def __str__(self):
return "{}".format(self.user.username) # pragma: no cover

class Meta:
ordering = ["-createdAt"]
ordering = ["-created_at"]
4 changes: 2 additions & 2 deletions authors/apps/reports/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class Meta:
'reporter',
'reported_article',
'reason',
'createdAt',
'updatedAt'
'created_at',
'updated_at'
)

extra_kwargs = {
Expand Down
Loading

0 comments on commit 90ab468

Please sign in to comment.