-
Notifications
You must be signed in to change notification settings - Fork 56
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
Fix #118: Added contest page functionality #129
Conversation
oshc/main/views.py
Outdated
|
||
contest.save() | ||
|
||
return HttpResponseRedirect("/contests/") |
There was a problem hiding this comment.
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
oshc/main/views.py
Outdated
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() |
There was a problem hiding this comment.
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 ','
oshc/main/views.py
Outdated
contest = Contest() | ||
contest.name = request.POST.get("name", "null") | ||
contest.link = request.POST.get("link", "null") | ||
start_date = request.POST.get("start_date","null") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
oshc/main/views.py
Outdated
|
||
|
||
def contest_new(request): | ||
return render(request,'contest_edit.html') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing whitespace after ','
oshc/main/views.py
Outdated
|
||
def contests(request): | ||
contest_list = Contest.objects.all() | ||
return render(request, 'contests.html', context={'contest_list':contest_list}) |
There was a problem hiding this comment.
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)
oshc/main/models.py
Outdated
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) |
There was a problem hiding this comment.
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)
oshc/main/models.py
Outdated
@@ -15,3 +15,13 @@ class chatSession(models.Model): | |||
|
|||
def __str__(self): | |||
return self.title | |||
|
|||
class Contest(models.Model): |
There was a problem hiding this comment.
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
Hi @vaibhavsingh97 @tapasweni-pathak |
@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 |
Hi @vaibhavsingh97, |
@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)), |
There was a problem hiding this comment.
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")), |
There was a problem hiding this comment.
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)), |
There was a problem hiding this comment.
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')), |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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)
('link', | ||
models.URLField(help_text="URL of the contest's website")), | ||
('description', models.TextField(help_text='Contest details', | ||
max_length=512)), |
There was a problem hiding this comment.
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)), |
There was a problem hiding this comment.
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')), |
There was a problem hiding this comment.
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
@abhishekarya286 One trick : Use autopep8 tool 😄 |
oshc/main/migrations/0001_initial.py
Outdated
('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)), |
There was a problem hiding this comment.
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)
oshc/main/migrations/0001_initial.py
Outdated
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")), |
There was a problem hiding this comment.
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)
oshc/main/migrations/0001_initial.py
Outdated
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)), |
There was a problem hiding this comment.
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)
oshc/main/migrations/0001_initial.py
Outdated
migrations.CreateModel( | ||
name='Contest', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
There was a problem hiding this comment.
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)
oshc/main/migrations/0001_initial.py
Outdated
('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)), |
There was a problem hiding this comment.
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)
oshc/main/migrations/0001_initial.py
Outdated
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")), |
There was a problem hiding this comment.
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)
oshc/main/migrations/0001_initial.py
Outdated
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)), |
There was a problem hiding this comment.
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)
oshc/main/migrations/0001_initial.py
Outdated
migrations.CreateModel( | ||
name='Contest', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
There was a problem hiding this comment.
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)
oshc/main/migrations/0001_initial.py
Outdated
('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")), |
There was a problem hiding this comment.
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)
oshc/main/migrations/0001_initial.py
Outdated
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)), |
There was a problem hiding this comment.
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)
oshc/main/migrations/0001_initial.py
Outdated
name='Contest', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, | ||
primary_key=True, serialize=False, verbose_name='ID')), |
There was a problem hiding this comment.
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)
oshc/main/migrations/0001_initial.py
Outdated
@@ -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')), |
There was a problem hiding this comment.
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)
oshc/main/migrations/0001_initial.py
Outdated
('name', models.CharField(help_text='Contest name', | ||
max_length=128)), | ||
('link', | ||
models.URLField(help_text="URL of the contest's website")), |
There was a problem hiding this comment.
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
oshc/main/migrations/0001_initial.py
Outdated
primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(help_text='Contest name', | ||
max_length=128)), | ||
('link', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing whitespace
oshc/main/migrations/0001_initial.py
Outdated
('id', models.AutoField(auto_created=True, | ||
primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(help_text='Contest name', | ||
max_length=128)), |
There was a problem hiding this comment.
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
oshc/main/migrations/0001_initial.py
Outdated
fields=[ | ||
('id', models.AutoField(auto_created=True, | ||
primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(help_text='Contest name', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing whitespace
oshc/main/migrations/0001_initial.py
Outdated
name='Contest', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, | ||
primary_key=True, serialize=False, verbose_name='ID')), |
There was a problem hiding this comment.
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
oshc/main/migrations/0001_initial.py
Outdated
@@ -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')), |
There was a problem hiding this comment.
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
@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. |
Hey!! @abhishekarya286 Can we talk on slack. Request your invite here 😄 |
oshc/main/views.py
Outdated
|
||
from main.models import chatSession | ||
from django.template import RequestContext |
There was a problem hiding this comment.
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
oshc/main/views.py
Outdated
|
||
from django.shortcuts import render_to_response | ||
|
||
from django.template import RequestContext | ||
from django.shortcuts import render_to_response |
There was a problem hiding this comment.
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
@vaibhavsingh97. Please review this PR. |
There was a problem hiding this 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)
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 😄
oshc/main/templates/contests.html
Outdated
<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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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??
oshc/main/views.py
Outdated
@@ -1,11 +1,14 @@ | |||
from django.shortcuts import render | |||
from django.http import HttpResponseRedirect | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove blank lines
oshc/main/views.py
Outdated
from django.http import HttpResponseRedirect | ||
|
||
from main.models import chatSession, Contest | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
oshc/main/views.py
Outdated
|
||
|
||
def add_contest(request): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
oshc/main/views.py
Outdated
start_date = request.POST.get("start_date", "null") | ||
end_date = request.POST.get("end_date", "null") | ||
contest.description = request.POST.get("desc", "null") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
oshc/main/views.py
Outdated
|
||
contest.end_date = datetime.strptime(end_date, '%Y-%m-%d').date() | ||
contest.start_date = datetime.strptime(start_date, '%Y-%m-%d').date() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@vaibhavsingh97, |
There was a problem hiding this 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', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abhishekarya286 is this pep8?
There was a problem hiding this comment.
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')),
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Hi, @tapasweni-pathak, |
@tapasweni-pathak, Any updates?? |
There was a problem hiding this 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. 🚀
@tapasweni-pathak, thanks for merging. |
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:

And the form:
