Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/api #1

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Feature/api #1

wants to merge 8 commits into from

Conversation

andreyPromaster
Copy link
Owner

No description provided.


@admin.register(Place)
class PlaceAdmin(OSMGeoAdmin):
list_display = ('name', 'location', 'address', 'image', 'type')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
list_display = ('name', 'location', 'address', 'image', 'type')
list_display = ('name', 'location', 'address', 'image', 'type', )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use black to evade '' and "" differences


@admin.register(Rate)
class RateAdmin(admin.ModelAdmin):
list_display = ("rating", "created_at", "user", "comment")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
list_display = ("rating", "created_at", "user", "comment")
list_display = ("rating", "created_at", "user", "comment", )


@admin.register(Place)
class PlaceAdmin(OSMGeoAdmin):
list_display = ('name', 'location', 'address', 'image', 'type')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use black to evade '' and "" differences

name='type',
field=models.CharField(default='shop', max_length=200),
),
]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Man, 12 migrations... There is squash option

path("ping", views.ping, name="index"),
path("places", PlaceListAPIView.as_view({"get": "list", "post": "create"}), name="place-list"),
path("places/<int:pk>/ratings", PlaceListAPIView.as_view({"post": "create_rating"}), name="comment-list"),
path("comments/<int:pk>/releted-comments", RelatedCommentAPIView.as_view({"post": "create_related_comment"}), name="related-comments")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
path("comments/<int:pk>/releted-comments", RelatedCommentAPIView.as_view({"post": "create_related_comment"}), name="related-comments")
path("comments/<int:pk>/related-comments", RelatedCommentAPIView.as_view({"post": "create_related_comment"}), name="related-comments")



def validate_rating(value):
if value < 0 or value > 5:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if value < 0 or value > 5:
if not 0 <= value <= 5:


from django.contrib.gis.geos import Point
from entertainment.models import Place, Rate, Comment
from entertainment.serializers import PlaceSerializer, RateSerializer, CommentSerializer


@api_view(['GET'])
def ping(request):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it relevant?

@@ -78,7 +81,7 @@

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': os.environ['DATABASE'],
'USER': "rating",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this not in env vars?

class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('username',)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are many files without empty line at the end of file


# Create your views here.
from .serializers import RegisterSerializer

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use absolute import

('location', django.contrib.gis.db.models.fields.PointField(srid=4326)),
('address', models.CharField(max_length=255)),
('image', models.ImageField(blank=True, null=True, upload_to='')),
('type', models.CharField(choices=[('cafe', 'Cafe'), ('restaurant', 'Restaurant'), ('sport', 'Sport'), ('tech', 'tech'), ('shop', 'Shop')], default='cafe', max_length=20)),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why max_length = 20, if longest choice is restaraunt which is 10 characters?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants