Skip to content

Fix #118: Added contest page functionality #129

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

Merged
merged 7 commits into from
Oct 14, 2017

Conversation

abarya
Copy link
Contributor

@abarya abarya commented Oct 6, 2017

I have added the functionality to view all the contests at one page. Also added a contest form using which any user can add information regarding the upcoming contests.

It looks likes this:
image

And the form:
image


contest.save()

return HttpResponseRedirect("/contests/")

Choose a reason for hiding this comment

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

no newline at end of file

end_date = request.POST.get("end_date", "null")
contest.description = request.POST.get("desc", "null")

contest.end_date=datetime.strptime(end_date,'%Y-%m-%d').date()

Choose a reason for hiding this comment

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

missing whitespace around operator
missing whitespace after ','

contest = Contest()
contest.name = request.POST.get("name", "null")
contest.link = request.POST.get("link", "null")
start_date = request.POST.get("start_date","null")

Choose a reason for hiding this comment

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

missing whitespace after ','



def contest_new(request):
return render(request,'contest_edit.html')

Choose a reason for hiding this comment

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

missing whitespace after ','


def contests(request):
contest_list = Contest.objects.all()
return render(request, 'contests.html', context={'contest_list':contest_list})

Choose a reason for hiding this comment

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

missing whitespace after ':'
line too long (82 > 79 characters)

class Contest(models.Model):
name = models.CharField(max_length=128, help_text="Contest name")
link = models.URLField(help_text="URL of the contest's website")
description = models.TextField(max_length=512, help_text="Contest details",null=True)

Choose a reason for hiding this comment

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

missing whitespace after ','
line too long (89 > 79 characters)

@@ -15,3 +15,13 @@ class chatSession(models.Model):

def __str__(self):
return self.title

class Contest(models.Model):

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

@abarya
Copy link
Contributor Author

abarya commented Oct 6, 2017

Hi @vaibhavsingh97 @tapasweni-pathak
Please review this.

@vaibhavsingh97
Copy link
Member

@abhishekarya286 Wow!! I am impressed 👏 👏 You have done an awesome job 🎉 🎉 . Can you please fix the suggestions of Hounds CI and also can you please add link in the form. Also, For the visual enhancement can we have something like this. Keep contributing 😄

@abarya
Copy link
Contributor Author

abarya commented Oct 6, 2017

Hi @vaibhavsingh97,
Thanks for reviewing. I added bootstrap to the contest page and it looks fine to me now.
Also, I don't know why The Travis CI build failed error. Please help me with this.

@vaibhavsingh97
Copy link
Member

@abhishekarya286 This error came because you havn't pushed migration file. Please push migration file than this error will be resolved

('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name', max_length=128)),
('link', models.URLField(help_text="URL of the contest's website")),
('description', models.TextField(help_text='Contest details', max_length=512)),

Choose a reason for hiding this comment

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

line too long (95 > 79 characters)

fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name', max_length=128)),
('link', models.URLField(help_text="URL of the contest's website")),

Choose a reason for hiding this comment

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

line too long (84 > 79 characters)

name='contests',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name', max_length=128)),

Choose a reason for hiding this comment

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

line too long (85 > 79 characters)

migrations.CreateModel(
name='contests',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),

Choose a reason for hiding this comment

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

line too long (114 > 79 characters)

migrations.AlterField(
model_name='contest',
name='description',
field=models.TextField(help_text='Contest details', max_length=512, null=True),

Choose a reason for hiding this comment

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

line too long (91 > 79 characters)

migrations.AlterField(
model_name='contest',
name='description',
field=models.TextField(help_text='Contest details', max_length=512, null=True),

Choose a reason for hiding this comment

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

line too long (91 > 79 characters)

@coveralls
Copy link

Coverage Status

Coverage decreased (-9.6%) to 80.612% when pulling 914fee7 on abhishekarya286:contestpage into ce318c9 on OpenSourceHelpCommunity:develop.

('link',
models.URLField(help_text="URL of the contest's website")),
('description', models.TextField(help_text='Contest details',
max_length=512)),

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name',
max_length=128)),

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

name='contests',
fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

@coveralls
Copy link

Coverage Status

Coverage decreased (-9.6%) to 80.612% when pulling aa64c74 on abhishekarya286:contestpage into ce318c9 on OpenSourceHelpCommunity:develop.

@vaibhavsingh97
Copy link
Member

vaibhavsingh97 commented Oct 7, 2017

@abhishekarya286 One trick : Use autopep8 tool 😄
Also, It's best that if you have changed any thing so before migrating delete old migration file. Can you please clean unnecessary migration files 😅 .
Sorry, If you are facing too much difficulty. You can DM me anytime, I am happy to help you 😄

@coveralls
Copy link

Coverage Status

Coverage decreased (-9.6%) to 80.612% when pulling 2dc1314 on abhishekarya286:contestpage into ce318c9 on OpenSourceHelpCommunity:develop.

('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name', max_length=128)),
('link', models.URLField(help_text="URL of the contest's website")),
('description', models.TextField(help_text='Contest details', max_length=512, null=True)),

Choose a reason for hiding this comment

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

line too long (106 > 79 characters)

fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name', max_length=128)),
('link', models.URLField(help_text="URL of the contest's website")),

Choose a reason for hiding this comment

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

line too long (84 > 79 characters)

name='Contest',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name', max_length=128)),

Choose a reason for hiding this comment

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

line too long (85 > 79 characters)

migrations.CreateModel(
name='Contest',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),

Choose a reason for hiding this comment

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

line too long (114 > 79 characters)

('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name', max_length=128)),
('link', models.URLField(help_text="URL of the contest's website")),
('description', models.TextField(help_text='Contest details', max_length=512, null=True)),

Choose a reason for hiding this comment

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

line too long (106 > 79 characters)

fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name', max_length=128)),
('link', models.URLField(help_text="URL of the contest's website")),

Choose a reason for hiding this comment

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

line too long (84 > 79 characters)

name='Contest',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name', max_length=128)),

Choose a reason for hiding this comment

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

line too long (85 > 79 characters)

migrations.CreateModel(
name='Contest',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),

Choose a reason for hiding this comment

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

line too long (114 > 79 characters)

@coveralls
Copy link

Coverage Status

Coverage decreased (-14.6%) to 75.641% when pulling b6d62e0 on abhishekarya286:contestpage into ce318c9 on OpenSourceHelpCommunity:develop.

('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name', max_length=128)),
('link', models.URLField(help_text="URL of the contest's website")),

Choose a reason for hiding this comment

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

line too long (84 > 79 characters)

fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name', max_length=128)),

Choose a reason for hiding this comment

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

line too long (85 > 79 characters)

name='Contest',
fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),

Choose a reason for hiding this comment

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

line too long (95 > 79 characters)

@@ -16,14 +16,32 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='chatSession',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),

Choose a reason for hiding this comment

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

line too long (95 > 79 characters)

@coveralls
Copy link

Coverage Status

Coverage decreased (-14.6%) to 75.641% when pulling 2f68269 on abhishekarya286:contestpage into ce318c9 on OpenSourceHelpCommunity:develop.

('name', models.CharField(help_text='Contest name',
max_length=128)),
('link',
models.URLField(help_text="URL of the contest's website")),

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name',
max_length=128)),
('link',

Choose a reason for hiding this comment

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

trailing whitespace

('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name',
max_length=128)),

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='Contest name',

Choose a reason for hiding this comment

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

trailing whitespace

name='Contest',
fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

@@ -16,14 +16,34 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='chatSession',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

@coveralls
Copy link

Coverage Status

Coverage decreased (-14.6%) to 75.641% when pulling 0b199f6 on abhishekarya286:contestpage into ce318c9 on OpenSourceHelpCommunity:develop.

@coveralls
Copy link

Coverage Status

Coverage decreased (-14.6%) to 75.641% when pulling d039763 on abhishekarya286:contestpage into ce318c9 on OpenSourceHelpCommunity:develop.

@coveralls
Copy link

Coverage Status

Coverage decreased (-8.9%) to 69.565% when pulling 0e753ff on abhishekarya286:contestpage into e88dada on OpenSourceHelpCommunity:develop.

@abarya
Copy link
Contributor Author

abarya commented Oct 7, 2017

@vaibhavsingh97, thanks for your help. But still, I'm having issues with hound CI. I've tried using autopep8 but it also didn't help much.
Can you suggest something?

@vaibhavsingh97
Copy link
Member

Hey!! @abhishekarya286 Can we talk on slack. Request your invite here 😄

@coveralls
Copy link

Coverage Status

Coverage decreased (-8.9%) to 69.565% when pulling 303513b on abhishekarya286:contestpage into e88dada on OpenSourceHelpCommunity:develop.


from main.models import chatSession
from django.template import RequestContext

Choose a reason for hiding this comment

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

redefinition of unused 'RequestContext' from line 10


from django.shortcuts import render_to_response

from django.template import RequestContext
from django.shortcuts import render_to_response

Choose a reason for hiding this comment

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

redefinition of unused 'render_to_response' from line 8

@coveralls
Copy link

Coverage Status

Coverage decreased (-8.2%) to 70.213% when pulling 2b8fe3f on abhishekarya286:contestpage into e88dada on OpenSourceHelpCommunity:develop.

@coveralls
Copy link

Coverage Status

Coverage decreased (-8.9%) to 69.565% when pulling 89ca22e on abhishekarya286:contestpage into e88dada on OpenSourceHelpCommunity:develop.

@abarya
Copy link
Contributor Author

abarya commented Oct 7, 2017

@vaibhavsingh97. Please review this PR.

Copy link
Member

@vaibhavsingh97 vaibhavsingh97 left a comment

Choose a reason for hiding this comment

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

Hi!! @abhishekarya286 can you convert current UI something like this and also make sure no content should come below icon (Refer screenshot)
image

We can use AdminDateWidget to get Django admin date, this will make things simple. As of now if enter wrong fomat of date result in 500 error (this error will be reduced). After merge I will open new issue for right feedback after user enter wrong data in the fireld 😄

<div class="panel panel-default">
<div class="panel-heading"><a href="{{contest.link}}">{{contest.name}}</a></div>
<div class="panel-body">
<strong>Start Date:</strong> {{contest.start_date}}<br>
Copy link
Member

Choose a reason for hiding this comment

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

don't use <br> instead make css class and use that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @vaibhavsingh97,
you said, "also make sure no content should come below icon (Refer screenshot)"
below which icon??

@@ -1,11 +1,14 @@
from django.shortcuts import render
from django.http import HttpResponseRedirect

Copy link
Member

Choose a reason for hiding this comment

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

Remove blank lines

from django.http import HttpResponseRedirect

from main.models import chatSession, Contest

Copy link
Member

Choose a reason for hiding this comment

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

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done



def add_contest(request):

Copy link
Member

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

start_date = request.POST.get("start_date", "null")
end_date = request.POST.get("end_date", "null")
contest.description = request.POST.get("desc", "null")

Copy link
Member

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


contest.end_date = datetime.strptime(end_date, '%Y-%m-%d').date()
contest.start_date = datetime.strptime(start_date, '%Y-%m-%d').date()

Copy link
Member

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@coveralls
Copy link

Coverage Status

Coverage decreased (-8.9%) to 69.565% when pulling a1092ca on abhishekarya286:contestpage into e88dada on OpenSourceHelpCommunity:develop.

@abarya
Copy link
Contributor Author

abarya commented Oct 8, 2017

@vaibhavsingh97,
I was unable to add a calendar using AdminDateWidget(). Other than this, please review.

Copy link
Member

@tapaswenipathak tapaswenipathak left a comment

Choose a reason for hiding this comment

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

Thanks for the work! I have received one email per houndci comment and your commit.:smile:, thanks for patiently fixing all the issues.

We need one more field in the table not visible on the UI which will say approved by the admin. Admin will login through django admin console and the manually say 'X' in the field for now, later we will allow admin to see submitted contest on their console. Submission of contests by the user needs to be reviewed by the admin first. After clicking on submit we need to "contest submitted for review".

('id', models.AutoField(auto_created=True,
primary_key=True,
serialize=False, verbose_name='ID')),
('title', models.CharField(help_text='Session title',
Copy link
Member

Choose a reason for hiding this comment

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

@abhishekarya286 is this pep8?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope. I had to manually do it like that so that hound ci error doesn't come. With hound ci, you'll get something like:
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reviewing @tapasweni-pathak,
So what I'm trying to do now is adding up a boolean field in the contest model which will be having a default value 0. So, when the user will submit the contest, the admin can then review it and if he/she finds that this contest can be put up on the website then he/she can change the boolean field to 1 and the contest will be displayed on the website. Is it okay?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, cool. Please go ahead.

@coveralls
Copy link

Coverage Status

Coverage decreased (-9.0%) to 69.474% when pulling e704eba on abhishekarya286:contestpage into e88dada on OpenSourceHelpCommunity:develop.

@abarya
Copy link
Contributor Author

abarya commented Oct 8, 2017

Hi, @tapasweni-pathak,
I have added a field for approval of submissions which will be visible in the console. Also, I have added a thank you page which will be shown after submission. Kindly review.

@abarya
Copy link
Contributor Author

abarya commented Oct 9, 2017

@tapasweni-pathak, Any updates??

Copy link
Member

@tapaswenipathak tapaswenipathak left a comment

Choose a reason for hiding this comment

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

@abhishekarya286 Thanks for the work!

You know I will be raising more issues after merging this, for checks, replacing form with crispy-forms but this is a great base to do the changes on! Merging this. 🚀

@tapaswenipathak tapaswenipathak merged commit bad80c8 into OpenSourceHelpCommunity:develop Oct 14, 2017
@abarya
Copy link
Contributor Author

abarya commented Oct 14, 2017

@tapasweni-pathak, thanks for merging.

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.

5 participants