Skip to content

Product/crud added.#14

Open
quratulain25 wants to merge 5 commits intomasterfrom
product/crud
Open

Product/crud added.#14
quratulain25 wants to merge 5 commits intomasterfrom
product/crud

Conversation

@quratulain25
Copy link
Copy Markdown
Collaborator

Ready for review.

@quratulain25 quratulain25 requested a review from Ayub-Khan October 6, 2020 05:33
Comment thread management/models.py
def __str__(self):
return self.title

def get_absolute_url(self):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This will cause code duplication you can create a helper method in a utils file. which takes the url as argument and returns the absolute url.
Now you will have to create method for each model.
If this is required by the model view we can keep this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the concept of get_absolute_url is understandable for me. I don't know how can I reduce code in utils.py or utils/absolute_urls.py. Could you refer some readings?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Its quite simple if its used by many classes it should be a seperate function. If its a functionality which contains multiple functions it should have its own class. If its core functionality it should exist in core files or should have its own core file.
If its a utility method and we can work without it. This should be moved to utility.py.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Its a two liner its fine to have it in all classes but comment is regarding the practice. Because having similar code repeated in all classes causes code duplication. Many ways to handle that. you can create your own parent model class which inherits from models.Model and have this method and then all other classes are inherited by that. or another way which is preferred here bcz its small functionality is to create a utility method.

Copy link
Copy Markdown
Collaborator Author

@quratulain25 quratulain25 Dec 17, 2020

Choose a reason for hiding this comment

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

Well, I am using builtin views like 'UpdateView', 'ListView' etc. These need an absolute urls that needs to be defined in Model. Apart from this, each model has different absolute url like Product model's absolute url leads to Product's list page while Company's functions leads to Company's list page.

Comment thread management/models.py
Comment thread management/views/__init__.py Outdated
Comment thread management/urls.py Outdated
@@ -10,18 +10,6 @@
from management.models import Company


class DashboardView(TemplateView):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Good Move.

Comment thread management/views/main.py Outdated
Comment thread management/views/product.py Outdated

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['title'] = 'LBM'
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

'LBM-Product List'

same for rest and you might wanna change for company as well.

{{ company.name }}
</h1>
<h5 class="up-sub-header">
Product Designer at Facebook
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

" Product Designer at Facebook" ???

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is the default information. I haven't customised this page according to our needs, yet.

Comment thread templates/main_menu.html
@@ -25,14 +26,8 @@ <h1 class="menu-page-header">
<span>Dashboard</span>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Does this redirect to dashboard as you remove the anchor ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This does redirect and is under anchor tag.

            <a href="{% url 'management:dashboard' %}">
                <div class="icon-w">
                    <div class="os-icon os-icon-layout"></div>
                </div>
                <span>Dashboard</span>
            </a>

Comment thread management/models.py
def __str__(self):
return self.title

def get_absolute_url(self):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Its a two liner its fine to have it in all classes but comment is regarding the practice. Because having similar code repeated in all classes causes code duplication. Many ways to handle that. you can create your own parent model class which inherits from models.Model and have this method and then all other classes are inherited by that. or another way which is preferred here bcz its small functionality is to create a utility method.

model = Product
template_name = 'product_management/view_product_profile.html'

def get_context_data(self, **kwargs):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We can do similar thing using Django Context Manager. We might do that in future.

<div class="col-sm-6">
<div class="form-group">
<label for=""> Name </label>
<input class="form-control" name="title"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

You might want to update html files as well to shows description field.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Already been added in last commit.

`

                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label> Description </label>
                                            <textarea class="form-control" rows="5" name="description"
                                                      placeholder="Anything you would like to add."> {{ product.description }} </textarea>
                                        </div>
                                    </div>
                                </div>`

value="{{ product.title }}"
data-error="Please input product's Name"
minlength="3" maxlength="60"
required="required" type="text">
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Description here as well

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Already been added in last commit.

`

                                    <div class="col-sm-6">
                                        <div class="form-group">
                                            <label> Description </label>
                                            <textarea class="form-control" rows="5" name="description"
                                                      placeholder="Anything you would like to add."> {{ product.description }} </textarea>
                                        </div>
                                    </div>
                                </div>`

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