Conversation
|
It is a very large PR. In order to have a review, I need to run it. There are no installation documentation in the repo. In this PR the only thing I see is;
|
Resolved! |
|
@nabin2004 can you fix these conflict? |
tekrajchhetri
left a comment
There was a problem hiding this comment.
Please fix the merge conflict.
There was a problem hiding this comment.
@nabin2004 @nirajkark is there a reason why we need to push the database?
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
There was a problem hiding this comment.
It would be nice to add the comments to describe what this code is.
"""
Migration for heritage data models.
Creates:
- Submission model with .....
Establishes relationships between users and submissions
"""
There was a problem hiding this comment.
this is also a best practices
| @@ -0,0 +1,35 @@ | |||
| from django.contrib import admin | |||
There was a problem hiding this comment.
@nabin2004 @nirajkark I would suggest adding something like shown below at the beginning of the code. I have configured the pycharm to do so. Whenever I create a new python code following is automatically added.
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# DISCLAIMER: This software is provided "as is" without any warranty,
# express or implied, including but not limited to the warranties of
# merchantability, fitness for a particular purpose, and non-infringement.
#
# In no event shall the authors or copyright holders be liable for any
# claim, damages, or other liability, whether in an action of contract,
# tort, or otherwise, arising from, out of, or in connection with the
# software or the use or other dealings in the software.
# -----------------------------------------------------------------------------
# @Author : <author-name>
# @Email : <cair-nepal-email-address>
# @File : <filename>
# @Software: PyCharm
| ] | ||
| title = models.CharField(max_length=255) | ||
| description = models.TextField() | ||
| contributor = models.ForeignKey(User, on_delete=models.CASCADE, related_name='submissions') |
There was a problem hiding this comment.
@nabin2004 We should not delete the submission if user is deleted for any reason. Remove the CASCADE option and change it to appropriate one.
| return f"{self.title} ({self.get_status_display()})" | ||
|
|
||
| class Moderation(models.Model): | ||
| submission = models.OneToOneField(Submission, on_delete=models.CASCADE, related_name='moderation') |
There was a problem hiding this comment.
@nabin2004 @nirajkark We don't want cascading, please adjust accordingly
There was a problem hiding this comment.
- Add the docstrings for all the code
|
|
||
|
|
||
| class UserProfileAdmin(admin.ModelAdmin): | ||
| list_display = ('user', 'organization', 'score','position','birth_date','university_school') |
| migrations.AlterField( | ||
| model_name='moderation', | ||
| name='submission', | ||
| field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='moderations', to='heritage_data.submission'), |
There was a problem hiding this comment.
@nirajkark @nabin2004 Update django.db.models.deletion.CASCADE, we don't want to CASCADE.
| # See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ | ||
|
|
||
| # SECURITY WARNING: keep the secret key used in production secret! | ||
| SECRET_KEY = 'django-insecure-03eebp+*3833bj!9v)r41dvnv8eg%#avt!eyq7s=kk8@&plg^$' |
There was a problem hiding this comment.
@nabin2004 @nirajkark use the environment variable for the key and do not hardcode it.
There was a problem hiding this comment.
you can use https://github.com/HBNetwork/python-decouple
Also following is the suggested security update.
from decouple import config
SECRET_KEY = config('DJANGO_SECRET_KEY')
DEBUG = config('DEBUG', default=False, cast=bool)
CORS_ALLOWED_ORIGINS = config('CORS_ORIGINS', default='').split(',')
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
],
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
'DEFAULT_THROTTLE_CLASSES': [
'rest_framework.throttling.AnonRateThrottle',
'rest_framework.throttling.UserRateThrottle'
],
'DEFAULT_THROTTLE_RATES': {
'anon': '100/day',
'user': '1000/day'
}
}
Description
This PR adds the structure for the Heritage graph application by adding both the frontend and backend directories. The frontend directory contains the React 18 application, while the backend directory includes the Django REST Framework setup for the core application.
Changes Made: