Skip to content
This repository has been archived by the owner on Mar 7, 2022. It is now read-only.

First sketch meetup model #6

Merged
merged 6 commits into from
Aug 31, 2017
Merged

First sketch meetup model #6

merged 6 commits into from
Aug 31, 2017

Conversation

SehoNoh
Copy link
Contributor

@SehoNoh SehoNoh commented Aug 29, 2017

This pull request is what I think about the seminar website's basic feature, not a perfect modeling.
So feel free to feedback me and let's discuss about this.

@darjeeling
Copy link
Contributor

  • no test for model
  • indent.. fixed

meetup/models.py Outdated
location = models.CharField(max_length=255, null=True)
description = models.TextField(null=True)
latitude = models.FloatField()
longitude = models.FloatField()
Copy link

Choose a reason for hiding this comment

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

Use PointField or DecimalField instead of FloatField.
FloatField has not enough precision to use lat, lng.

meetup/models.py Outdated
@@ -1,3 +1,62 @@
from uuid import uuid4

from django.contrib.auth.models import User
Copy link

Choose a reason for hiding this comment

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

from django.contrib.auth import get_user_model
User = get_user_model()

get_user_model() provide more flexibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"""This model is for that lecture or event by speaker(s)"""
# There should be difficulty and language information in Program?
title = models.CharField(max_length=255)
brief = models.TextField(null=True, verbose_name='simple information')
Copy link

Choose a reason for hiding this comment

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

from django.utils.translation import ugettext as _
verbose_name=_('simple information')

Please use gettext to description text translation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On my plan, I will translate whole words later at once.
But I think, you are not agree with me. are you?

Copy link

Choose a reason for hiding this comment

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

I agree with you.
I think gettext is still right choice if your plan include i18n.

Copy link
Contributor Author

@SehoNoh SehoNoh Aug 29, 2017

Choose a reason for hiding this comment

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

Thank you, I want to use the i18n and L10n on this project and PyCon Korea Website, for Best Practice :)

meetup/models.py Outdated
description = models.TextField(null=True)
speakers = models.ManyToManyField(Speaker)
category = models.ForeignKey(ProgramCategory, verbose_name='The category which this program is belonged')
slide_url = models.CharField(max_length=255, null=True, verbose_name='A slide url')
Copy link

Choose a reason for hiding this comment

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

meetup/models.py Outdated

class Profile(models.Model):
"""This model is for which profile for user"""
user = models.ForeignKey(User)
Copy link

Choose a reason for hiding this comment

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

I believe it should be OneToOneField.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

meetup/models.py Outdated
"""This model is for which profile for user"""
user = models.ForeignKey(User)
name = models.CharField(max_length=50)
slug = models.SlugField(max_length=50, unique=True, verbose_name='nickname')
Copy link

Choose a reason for hiding this comment

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

Common use case of slug is make url for specific object. That is reason why slugfield cannot use space. But 'nickname' is nickname. Nickname need space, Korean character and special character also.
So make new field for nickname is more make sense to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then, can I use that nickname as the slug like that Noh Seho to Noh-Seho?
or the slug variable should be changed the name to username? The username what I think means that the username is not allowed space.

Copy link

Choose a reason for hiding this comment

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

If you have plan to provide url for each profiles then keep this slug field and just change verbose_name 😄 .
and also you can use nickname field as slug. But that is not a good idea in performance reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, thank you

meetup/models.py Outdated
created_at = models.DateTimeField(auto_now_add=True)

def save(self, *args, **kwargs):
self.token = str(uuid4())
Copy link

Choose a reason for hiding this comment

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

@@ -1,3 +1,4 @@
django==1.11.4
psycopg2==2.7.3
uWSGI==2.0.15
Pillow==4.2.1
Copy link

Choose a reason for hiding this comment

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

I have two different opinion of this.

  1. Use pillow-simd (https://github.com/uploadcare/pillow-simd)
    pillow-simd is highly optimized version of pillow. You can get more than 2 times performance benefit with tiny effort. But it just opinion. I cannot strongly recommend it.
  2. Add this package when it need.
    I cannot found any image proccessing code yet. so.. why we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. OK
  2. When I run the python manage.py sqlmigrate or something about django command, django framework has verifed about that ImageField required the Pillow dependency https://docs.djangoproject.com/en/1.11/ref/models/fields/#imagefield

and I will not spend much time with huge effort about image processing before that would be needed.

"""This test class is for proving that the relationship among declared django models are organized successfully"""

def test_user_has_the_profile(self):
"""This test is for proving that a user has a profile"""
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can add attribute exist check.
you can use model meta before creating instance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That means, verifing the models' attributes between model what I made on models.py and model what I declared in test?

Copy link
Contributor

Choose a reason for hiding this comment

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

@NohSeho yes. IMHO declaration should be tested. In my case, I start to test from import

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, I will add that test code soon

@darjeeling
Copy link
Contributor

LGTM and we can go

@darjeeling darjeeling merged commit 9a782ee into pythonkr:master Aug 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants