Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class IssueEditForm(forms.ModelForm):

class Meta:
model = Issue
fields = ['description', 'screenshot']
fields = ['description', 'screenshot', 'label']
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is a required element.

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 didn't get this part. Could be a bit more explicit?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can set the attributes of the form in the backend. So, if we declare a required clause within the form definition in the backend -- It'll make sure that it is required when it is rendered and thus form submission is declined if it is not filled. It also solves the problem that you asked on Slack.
https://docs.djangoproject.com/en/1.11/ref/forms/fields/#django.forms.Field.required



class FormInviteFriend(forms.ModelForm):
Expand Down
20 changes: 20 additions & 0 deletions website/migrations/0027_issue_label.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2017-06-09 12:43
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('website', '0026_auto_20170606_2049'),
]

operations = [
migrations.AddField(
model_name='issue',
name='label',
field=models.PositiveSmallIntegerField(choices=[(1, b'Number Error'), (2, b'Functional'), (3, b'Performance'), (4, b'Security'), (5, b'Typo'), (6, b'Design'), (0, b'Unspecified')], default=0),
),
]
10 changes: 10 additions & 0 deletions website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,20 @@ def validate_image(fieldfile_obj):


class Issue(models.Model):
labels = (
(0, 'General'),
(1, 'Number Error'),
(2, 'Functional'),
(3, 'Performance'),
(4, 'Security'),
(5, 'Typo'),
(6, 'Design')
)
user = models.ForeignKey(User, null=True, blank=True)
domain = models.ForeignKey(Domain, null=True, blank=True)
url = models.URLField()
description = models.TextField()
label = models.PositiveSmallIntegerField(choices=labels, default=0)
views = models.IntegerField(null=True, blank=True)
status = models.CharField(max_length=10, default="open", null=True, blank=True)
user_agent = models.CharField(max_length=255, default="", null=True, blank=True)
Expand Down
5 changes: 5 additions & 0 deletions website/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ a:hover{
font-weight: initial;
position: absolute;
top: 80px;
width: 85%;
}
.activity-screenshot {
float:right;
Expand Down Expand Up @@ -443,4 +444,8 @@ input[type='file'] {
}
.issue_count a:hover{
color: #dd4252;
}
.bug-type {
position: absolute;
right: 20px;
}
1 change: 1 addition & 0 deletions website/templates/_activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
{% endif %}
{{ activity.verb }} <a href="/domain/{{ activity.target.domain_name }}">{{ activity.target.domain_title }}</a> {{ activity.timestamp|timesince }} ago |
<a href="//{{ activity.target.domain_name }}">{{ activity.target.domain_name }}</a>
<span class="label label-info bug-type">{{activity.target.get_label_display}}</span>
</div>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions website/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@
<label id="description-error" class="error" for="description">{{form.description.errors}}</label>
{% endif %}
</div>
<select name="label" class="form-control">
<option value="0" selected="selected">Bug Type</option>
<option value="1">Number error</option>
<option value="2">Functional</option>
<option value="3">Performance</option>
<option value="4">Security</option>
<option value="5">Typo</option>
<option value="6">Design</option>
</select>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be rendered from the backend instead of hard coding the properties here. It'll guarantee a safe submission of our attribute integrity on both the sides.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although I have rendered the form element in the edit page from the backend, I couldn't do it in base.html. I am new to Django and would love to see how to do this. Could you please change this part on top of my commit?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jajodiaraghav -- What issue are you facing while using it in base.html ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

{{form.label}} does not render anything in base.html. I did it in a way similar to the one in issue_edit.html. It took me a lot of time trying to debug, but all in vain. Can we merge this and fix the base.html in a different commit. I want to work on issue_edit.html page but couldn't, as it would result in conflicts unless this gets merged.

Or else, please help me fix this.

Thanks :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Have a look at website/forms.py (IssueEditForm). The current implementation of the bug submission form needs a complete redesign. Maybe, we can do it completely on another PR.

<div class="form-group">
<!-- <label>Attach Screenshot</label> -->
{% if request.GET.hash %}</br>
Expand Down
2 changes: 2 additions & 0 deletions website/templates/issue_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ <h1>Edit issue {{issue.pk}}</h1>
<label id="description-error" class="error" for="description">{{form.description.errors}}</label>
{% endif %}
</div>

{{form.label}}

<div class="form-group">
<label>Attach Screenshot</label>
Expand Down
2 changes: 1 addition & 1 deletion website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def process_issue(self, user, obj, created, domain, score=3):

class IssueCreate(IssueBaseCreate, CreateView):
model = Issue
fields = ['url','description','screenshot','domain']
fields = ['url','description','screenshot','domain', 'label']
template_name = "index.html"

def get_initial(self):
Expand Down