Skip to content

Newsletters models and migration files added. #233

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

Open
wants to merge 3 commits into
base: newsletters
Choose a base branch
from

Conversation

dhruvhacks
Copy link
Member

This PR contains the models and migration files for the infoconnect-newsletters section as developed in #232 .

return "%s" % (self.department)


class papers(models.Model):
Copy link
Member

Choose a reason for hiding this comment

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

Please change it to Newsletter.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay sir.

'''
Stores the pdfs of newsletters
'''
name = models.CharField(null=False,
Copy link
Member

Choose a reason for hiding this comment

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

Change name to title

Copy link
Member Author

Choose a reason for hiding this comment

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

okay sir. will change this.

'''
name = models.CharField(null=False,
max_length=25)
uploaded_by = models.ForeignKey(User)
Copy link
Member

Choose a reason for hiding this comment

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

I think this field must be linked to FacultyDetail model.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes sir, I did not notice this existing model. Will update this.

from django.contrib.auth.models import User


class department(models.Model):
Copy link
Member

Choose a reason for hiding this comment

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

@dhruvhacks Is there a need of creating this model ? I think only faculties can upload the newsletters and you can find their department in the FacultyDetail table. Please let me know your thoughts over it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@RishabhJain2018
Sir, while developing this feature, I created this model since every department will have multiple newsletters. Having department as an attribute within newsletters model will make redundant entries within it. A separate model will help more organised structure where all newsletters will be stored within one model linked to their respective departments.
Please tell if there is an alternative. 🙂

year = models.DateField()
paper = models.FileField(upload_to="newsletters", blank=False, null=False)
department = models.ForeignKey(department)

Copy link
Member

Choose a reason for hiding this comment

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

Please add created_by and modified_by fields.

Copy link
Member Author

@dhruvhacks dhruvhacks May 31, 2018

Choose a reason for hiding this comment

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

@RishabhJain2018 uploaded_by attribute already exists in the model which will be linked to FacultyDetail model. So should I still add created_by attribute ??
Moreover, we may add created_at and modified_at attributes which may help in tracking the changes.

@dhruvhacks dhruvhacks changed the base branch from master to newsletters June 1, 2018 22:41
@dhruvhacks dhruvhacks force-pushed the newsletters-models branch from e6a3a42 to ff36cb7 Compare June 1, 2018 22:58
'''
department = models.CharField(max_length=50,
blank=False,
null=False)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need this explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay sir. I'll merge this into newsletters model itself.

Stores the detail of department linked with its newsletters
'''
department = models.CharField(max_length=50,
blank=False,
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need this explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay sir. I'll shift this into newsletters model itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

@deshraj
Sir, I revised the model and felt we must keep it separate for easy management of newsletters. While designing this model I categorized all the newsletters into their respective departments. By having a separate model for department, we can easily link all the newsletters to a common department. Making it as an attribute in one model will dissolve the categories.
This categorization can be viewed in django admin-
Below screenshot displays all the departments which lists all the newsletters of that department.
image

Under any department, all it's newsletters can be managed this way-
image

Please sir let me know your thoughts over it. I'll make the changes accordingly. 🙂

Stores the pdfs of newsletters
'''
title = models.CharField(null=False,
max_length=25)
Copy link
Member

Choose a reason for hiding this comment

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

Shift this to the previous line.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay sir.

'''
title = models.CharField(null=False,
max_length=25)
uploaded_by = models.ForeignKey(User)
Copy link
Member

Choose a reason for hiding this comment

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

Add related_model attribute here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay sir. Will add this.

uploaded_by = models.ForeignKey(User)
year = models.DateField()
paper = models.FileField(upload_to="newsletters",
blank=False,
Copy link
Member

Choose a reason for hiding this comment

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

Remove this

year = models.DateField()
paper = models.FileField(upload_to="newsletters",
blank=False,
null=False)
Copy link
Member

Choose a reason for hiding this comment

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

Remove this.

created_at = models.DateTimeField()
modified_at = models.DateTimeField()

def create_newsletter(self):
Copy link
Member

Choose a reason for hiding this comment

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

Can you please tell me the use case of this method?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sir, I had in mind of writing some test cases for this model but did not frame them. Will remove it for now and add this in a separate PR with test cases.

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.

3 participants