summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fossee_anime/settings.py2
-rw-r--r--fossee_manim/forms.py41
-rw-r--r--fossee_manim/models.py4
-rw-r--r--fossee_manim/templates/fossee_manim/edit_proposal.html3
-rw-r--r--fossee_manim/templates/fossee_manim/register.html (renamed from fossee_manim/templates/fossee_manim/registration/register.html)0
-rw-r--r--fossee_manim/templates/fossee_manim/search_results.html6
-rw-r--r--fossee_manim/templates/registration/base.html99
-rw-r--r--fossee_manim/templates/registration/password_change_done.html (renamed from fossee_manim/templates/fossee_manim/password_change_done.html)0
-rw-r--r--fossee_manim/templates/registration/password_change_form.html (renamed from fossee_manim/templates/fossee_manim/password_change_form.html)0
-rw-r--r--fossee_manim/templates/registration/password_reset_complete.html (renamed from fossee_manim/templates/fossee_manim/password_reset_complete.html)1
-rw-r--r--fossee_manim/templates/registration/password_reset_confirm.html (renamed from fossee_manim/templates/fossee_manim/password_reset_confirm.html)0
-rw-r--r--fossee_manim/templates/registration/password_reset_done.html (renamed from fossee_manim/templates/fossee_manim/password_reset_done.html)0
-rw-r--r--fossee_manim/templates/registration/password_reset_form.html (renamed from fossee_manim/templates/fossee_manim/password_reset_form.html)2
-rw-r--r--fossee_manim/tests/test_models.py8
-rw-r--r--fossee_manim/tests/test_views.py2
-rw-r--r--fossee_manim/urls_password_reset.py7
-rw-r--r--fossee_manim/views.py16
17 files changed, 153 insertions, 38 deletions
diff --git a/fossee_anime/settings.py b/fossee_anime/settings.py
index 3004184..02aefb2 100644
--- a/fossee_anime/settings.py
+++ b/fossee_anime/settings.py
@@ -42,12 +42,12 @@ ALLOWED_HOSTS = []
INSTALLED_APPS = [
'django.contrib.admin',
+ 'fossee_manim',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
- 'fossee_manim',
'taggit',
'simple_history'
]
diff --git a/fossee_manim/forms.py b/fossee_manim/forms.py
index a1922ff..8edfb5c 100644
--- a/fossee_manim/forms.py
+++ b/fossee_manim/forms.py
@@ -24,16 +24,17 @@ position_choices = (
)
department_choices = (
- ("computer engineering", "Computer Science"),
- ("information technology", "Information Technology"),
- ("civil engineering", "Civil Engineering"),
- ("electrical engineering", "Electrical Engineering"),
- ("mechanical engineering", "Mechanical Engineering"),
- ("chemical engineering", "Chemical Engineering"),
- ("aerospace engineering", "Aerospace Engineering"),
+ ("computer", "Dept. of Computers"),
+ ("mathematics", "Dept. of Mathematics"),
+ ("physics", "Dept. of Physics"),
+ ("civil", "Dept. of Civil"),
+ ("electrical", "Dept. of Electrical"),
+ ("mechanical", "Dept. of Mechanical"),
+ ("chemical", "Dept. of Chemical"),
+ ("aerospace", "Dept. of Aerospace"),
("biosciences and bioengineering", "Biosciences and BioEngineering"),
- ("electronics", "Electronics"),
- ("energy science and engineering", "Energy Science and Engineering"),
+ ("electronics", "Dept. of Electronics"),
+ ("energy science and engineering", "Dept. of Energy Science and Engineering"),
("others", "Others")
)
@@ -97,13 +98,20 @@ states = (
)
+def check_upper(uname):
+ for a in uname:
+ if a.isupper():
+ return True
+ return False
+
+
class UserRegistrationForm(forms.Form):
"""A Class to create new form for User's Registration.
It has the various fields and functions required to register
a new user to the system"""
required_css_class = 'required'
errorlist_css_class = 'errorlist'
- username = forms.CharField(max_length=32, help_text='''Letters, digits,
+ username = forms.CharField(max_length=32, help_text='''lowercase, letters, digits,
period and underscore only.''')
email = forms.EmailField()
password = forms.CharField(max_length=32, widget=forms.PasswordInput())
@@ -124,6 +132,7 @@ class UserRegistrationForm(forms.Form):
department = forms.ChoiceField(help_text='Department you work/study',
choices=department_choices)
location = forms.CharField(max_length=255, help_text="Place/City")
+ pincode = forms.RegexField(regex=r'^.{6}$', error_messages={'invalid': "Please enter valid PINCODE"})
state = forms.ChoiceField(choices=states)
how_did_you_hear_about_us = forms.ChoiceField(choices=source)
@@ -133,6 +142,8 @@ class UserRegistrationForm(forms.Form):
msg = "Only letters, digits, period are"\
" allowed in username"
raise forms.ValidationError(msg)
+ if check_upper(u_name):
+ raise forms.ValidationError("lowercase only!")
try:
User.objects.get(username__exact=u_name)
raise forms.ValidationError("Username already exists.")
@@ -179,6 +190,7 @@ class UserRegistrationForm(forms.Form):
new_profile.location = cleaned_data["location"]
new_profile.title = cleaned_data["title"]
new_profile.state = cleaned_data["state"]
+ new_profile.pincode = cleaned_data["pincode"]
new_profile.how_did_you_hear_about_us = cleaned_data["how_did_you_hear_about_us"]
new_profile.activation_key = generate_activation_key(new_user.username)
new_profile.key_expiry_time = timezone.now() + timezone.timedelta(
@@ -237,17 +249,14 @@ class AnimationProposal(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(AnimationProposal, self).__init__(*args, **kwargs)
- self.fields['github'].widget.attrs['rows'] = 1
- self.fields['github'].widget.attrs['cols'] = 50
- self.fields['github'].widget.attrs['placeholder'] = 'Put your repo\
- link here'
- self.fields['description'].widget.attrs['placeholder'] = 'NOTE:-Do\
+ self.fields['subcategory'].widget.attrs['placeholder'] = 'Eg: Quantum Mechanics, Topology'
+ self.fields['outline'].widget.attrs['placeholder'] = 'NOTE:-Do\
add info about prerequisites if any also possible textbooks or \
other related information'
class Meta:
model = Animation
- fields = ['category', 'title', 'description', 'github', 'tags']
+ fields = ['category', 'subcategory', 'title', 'outline', 'tags']
class CommentForm(forms.ModelForm):
diff --git a/fossee_manim/models.py b/fossee_manim/models.py
index bdf1efc..dbd089b 100644
--- a/fossee_manim/models.py
+++ b/fossee_manim/models.py
@@ -164,10 +164,10 @@ class Animation(models.Model):
contributor = models.ForeignKey(User, on_delete=models.CASCADE)
reviewer = models.ForeignKey(User, null=True, on_delete=models.CASCADE,
related_name="%(app_label)s_%(class)s_related")
- description = models.TextField()
+ outline = models.TextField()
status = models.CharField(max_length=255, choices=status)
- github = models.TextField()
category = models.ForeignKey(Category, on_delete=models.CASCADE)
+ subcategory = models.CharField(max_length=255, blank=True)
created = models.DateTimeField(default=timezone.now)
tags = TaggableManager()
history = HistoricalRecords()
diff --git a/fossee_manim/templates/fossee_manim/edit_proposal.html b/fossee_manim/templates/fossee_manim/edit_proposal.html
index e42a358..55c0f75 100644
--- a/fossee_manim/templates/fossee_manim/edit_proposal.html
+++ b/fossee_manim/templates/fossee_manim/edit_proposal.html
@@ -31,6 +31,9 @@
<button class="btn btn-success" type="submit">Upload</button>
</label>
</form>
+ {% elif proposal_form.instance.status == 'pending' %}
+ <h3>Awaiting Reviewer's Moderation </h3>
+
{% else %}
<video width="100%" height="100%" controls>
<source src="{{video.0.video_path.url}}" type="video/mp4">
diff --git a/fossee_manim/templates/fossee_manim/registration/register.html b/fossee_manim/templates/fossee_manim/register.html
index 5b148a9..5b148a9 100644
--- a/fossee_manim/templates/fossee_manim/registration/register.html
+++ b/fossee_manim/templates/fossee_manim/register.html
diff --git a/fossee_manim/templates/fossee_manim/search_results.html b/fossee_manim/templates/fossee_manim/search_results.html
index 744f953..e58616b 100644
--- a/fossee_manim/templates/fossee_manim/search_results.html
+++ b/fossee_manim/templates/fossee_manim/search_results.html
@@ -10,7 +10,8 @@
<br>
<hr>
- <br>
+ <br>
+ {%if s_result %}
{% for anime in s_result %}
<div class="row">
<div class="col-md-4" >
@@ -27,6 +28,9 @@
</div>
<hr>
{% endfor %}
+ {% else %}
+ <h3>No Results Found </h3>
+ {% endif %}
<br>
</div>
<br>
diff --git a/fossee_manim/templates/registration/base.html b/fossee_manim/templates/registration/base.html
new file mode 100644
index 0000000..1a4945d
--- /dev/null
+++ b/fossee_manim/templates/registration/base.html
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>
+ {% block title %}
+ HomePage
+ {% endblock %}
+ </title>
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
+ <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.bundle.min.js"></script>
+
+ <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
+
+ <link rel="stylesheet" href="{{ URL_ROOT }}/static/css/sticky-footer.css" type="text/css" />
+ <!-- favicon -->
+ <link rel="shortcut icon" type="image/png" href="{{ URL_ROOT}}/"/>
+</head>
+
+ <!-- For js/ajax and other related scripts -->
+ {% block extra %}
+
+ {% endblock %}
+
+<body style="overflow: scroll;">
+ {% block header %}
+ <nav class="navbar navbar-expand-lg navbar-custom">
+ <a class="navbar-brand" href="#">FOSSEE Animations</a>
+ <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
+ aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
+ <span class="navbar-toggler-icon">=</span>
+ </button>
+
+ <div class="collapse navbar-collapse" id="navbarSupportedContent">
+ <ul class="navbar-nav mr-auto">
+ <form class="form-inline" method="POST" action="/search/">
+ {% csrf_token %}
+ <input class="form-control mr-sm-2" id="sbox" name="sbox" type="search" placeholder="Search" aria-label="Search">
+ <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
+ </form>
+ <li class="nav-item dropdown">
+ <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ Categories
+ </a>
+
+ <div class="dropdown-menu" aria-labelledby="navbarDropdown">
+ {% for c in categories %}
+ <a class="dropdown-item" href="{% url 'search_category' c.name %}">{{c.name}}</a>
+ {% endfor %}
+ </div>
+ </li>
+ </ul>
+
+ {% if user.is_authenticated %}
+ <ul class="navbar-nav ml-auto mr-5">
+ <li class="nav-item dropdown">
+ <a class="nav-link dropdown-toggle" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ {{user.first_name}}
+ </a>
+ {% if request.user.profile.position == 'contributor' %}
+ <div class="dropdown-menu" aria-labelledby="navbarDropdown">
+ <a class="dropdown-item" href="{% url 'how_to' %}">How To</a>
+ <a class="dropdown-item" href="{% url 'send_proposal' %}">Send Proposal</a>
+ <a class="dropdown-item" href="{% url 'proposal_status' %}">Proposal Status</a>
+ <a class="dropdown-item" href="{% url 'view_profile' %}">View Profile</a>
+ <a class="dropdown-item" href="{% url 'logout' %}">Logout</a>
+ </div>
+ {% else %}
+ <div class="dropdown-menu" aria-labelledby="navbarDropdown">
+ <a class="dropdown-item" href="{% url 'proposal_status' %}">Proposal Status</a>
+ <a class="dropdown-item" href="{% url 'view_profile' %}">View Profile</a>
+ <a class="dropdown-item" href="{% url 'logout' %}">Logout</a>
+ </div>
+ {% endif %}
+ </li>
+ </ul>
+ {% else %}
+ <ul class="navbar-nav ml-auto">
+ <li class="nav-item">
+ <a class="nav-link" href="{% url 'register' %}">Register</a>
+ </li>
+ <li class="nav-item">
+ <a class="nav-link" href="{% url 'login' %}">Login</a>
+ </li>
+ </ul>
+ {% endif %}
+ </div>
+ </nav>
+ {% endblock %}
+
+ {% block content %}
+ <br><br>
+ <h1>Base Template Content. Please override me</h1>
+ {% endblock %}
+
+</body>
+<br>
+</html> \ No newline at end of file
diff --git a/fossee_manim/templates/fossee_manim/password_change_done.html b/fossee_manim/templates/registration/password_change_done.html
index 93b93cb..93b93cb 100644
--- a/fossee_manim/templates/fossee_manim/password_change_done.html
+++ b/fossee_manim/templates/registration/password_change_done.html
diff --git a/fossee_manim/templates/fossee_manim/password_change_form.html b/fossee_manim/templates/registration/password_change_form.html
index 918f820..918f820 100644
--- a/fossee_manim/templates/fossee_manim/password_change_form.html
+++ b/fossee_manim/templates/registration/password_change_form.html
diff --git a/fossee_manim/templates/fossee_manim/password_reset_complete.html b/fossee_manim/templates/registration/password_reset_complete.html
index 99f8782..1ff3f76 100644
--- a/fossee_manim/templates/fossee_manim/password_reset_complete.html
+++ b/fossee_manim/templates/registration/password_reset_complete.html
@@ -1,4 +1,5 @@
{% extends "base.html" %}
+
{% block pagetitle %}Password reset complete{% endblock %}
{% block content %}
<p>Your password has been reset. </p>
diff --git a/fossee_manim/templates/fossee_manim/password_reset_confirm.html b/fossee_manim/templates/registration/password_reset_confirm.html
index 9f5b47a..9f5b47a 100644
--- a/fossee_manim/templates/fossee_manim/password_reset_confirm.html
+++ b/fossee_manim/templates/registration/password_reset_confirm.html
diff --git a/fossee_manim/templates/fossee_manim/password_reset_done.html b/fossee_manim/templates/registration/password_reset_done.html
index 0d335b8..0d335b8 100644
--- a/fossee_manim/templates/fossee_manim/password_reset_done.html
+++ b/fossee_manim/templates/registration/password_reset_done.html
diff --git a/fossee_manim/templates/fossee_manim/password_reset_form.html b/fossee_manim/templates/registration/password_reset_form.html
index 977fbc3..c67fdfc 100644
--- a/fossee_manim/templates/fossee_manim/password_reset_form.html
+++ b/fossee_manim/templates/registration/password_reset_form.html
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block pagetitle %}
- Email will be send to the registered email address
+ Email will be send to the registered email address
{% endblock %}
{% block content %}
diff --git a/fossee_manim/tests/test_models.py b/fossee_manim/tests/test_models.py
index 8b2162c..ab74123 100644
--- a/fossee_manim/tests/test_models.py
+++ b/fossee_manim/tests/test_models.py
@@ -26,7 +26,7 @@ def setUpModule():
category1 = Category.objects.create(name='Math', description='Mathematics')
reviewer_profile = Profile.objects.create(user=testUser2, position='reviewer',
- department='computer engineering', institute='ace', phone_number='1122334456',
+ department='computer science', institute='ace', phone_number='1122334456',
title='Doctor', how_did_you_hear_about_us='Google', location='powai', state='IN-MH',
is_email_verified=1)
@@ -55,7 +55,7 @@ class ProfileModelTest(TestCase):
self.demouser1 = User.objects.get(username='demouser1')
self.reviewer_profile1 = Profile.objects.create(user=self.testuser1,
- position='reviewer', department='computer engineering',
+ position='reviewer', department='computer science',
institute='ace', phone_number='1123323344',
title='Doctor', how_did_you_hear_about_us='Google', location='powai', state='IN-MH',
is_email_verified=1)
@@ -98,7 +98,7 @@ class AnimationModelTest(TestCase):
email='test.user@gmail.com', password='pass@123')
self.category1 = Category.objects.create(name='Biology', description='study of nature')
self.animation1 = Animation.objects.create(title='Testing Anime', contributor=self.demoUser2,
- reviewer=self.testUser2, description='This is test animation upload', github='https://github.come/FOSSEE',
+ reviewer=self.testUser2, outline='This is test animation upload',
category=self.category1)
def test_animation_model(self):
@@ -114,7 +114,7 @@ class CommentModelTest(TestCase):
email='test.user@gmail.com', password='pass@123')
self.category1 = Category.objects.create(name='Biology', description='study of nature')
self.animation1 = Animation.objects.create(title='Testing Anime', contributor=self.demoUser2,
- reviewer=self.testUser2, description='This is test animation upload', github='https://github.come/FOSSEE',
+ reviewer=self.testUser2, outline='This is test animation upload',
category=self.category1)
self.comment1 = Comment.objects.create(comment='This is a comment', commentor=self.testUser2,
animation=self.animation1, animation_status='changes')
diff --git a/fossee_manim/tests/test_views.py b/fossee_manim/tests/test_views.py
index 4d77bfe..525bd30 100644
--- a/fossee_manim/tests/test_views.py
+++ b/fossee_manim/tests/test_views.py
@@ -28,7 +28,7 @@ class TestProfile(TestCase):
self.user2_profile = Profile.objects.create(
user=self.user2,
- department='Computer Engineering',
+ department='Computer Science',
institute='ace',
title='Doctor',
position='instructor',
diff --git a/fossee_manim/urls_password_reset.py b/fossee_manim/urls_password_reset.py
index c784aa1..e60a8d6 100644
--- a/fossee_manim/urls_password_reset.py
+++ b/fossee_manim/urls_password_reset.py
@@ -2,10 +2,13 @@ from django.conf.urls import url
from django.contrib.auth.views import password_reset, password_reset_confirm,\
password_reset_done, password_reset_complete, password_change,\
password_change_done
+from django.contrib.auth import views as auth_views
+
urlpatterns = [
- url(r'^forgotpassword/$', password_reset,
- name="password_reset"),
+ url(r'^forgotpassword/$',auth_views.PasswordResetView.as_view(
+ template_name='registration/password_reset_form.html'
+ )),
url(r'^password_reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
password_reset_confirm,
name='password_reset_confirm'),
diff --git a/fossee_manim/views.py b/fossee_manim/views.py
index 9087a5f..feb23de 100644
--- a/fossee_manim/views.py
+++ b/fossee_manim/views.py
@@ -188,7 +188,7 @@ def user_register(request):
return redirect('/view_profile/')
categories = Category.objects.all()
return render(
- request, "fossee_manim/registration/register.html",
+ request, "fossee_manim/register.html",
{"form": form, 'categories': categories})
else:
categories = Category.objects.all()
@@ -197,7 +197,7 @@ def user_register(request):
elif request.user.is_authenticated():
return render(request, 'fossee_manim/activation.html')
form = UserRegistrationForm()
- return render(request, "fossee_manim/registration/register.html", {'form': form, 'categories': categories})
+ return render(request, "fossee_manim/register.html", {'form': form, 'categories': categories})
@login_required
@@ -282,13 +282,9 @@ def send_proposal(request):
form_data = form.save(commit=False)
form_data.contributor = user
form_data.status = "pending"
- if check_repo(form_data.github):
- form_data.save()
- form.save_m2m()
- # makepath(form_data)
- else:
- messages.warning(request, 'Please enter valid github details')
- return render(request, 'fossee_manim/send_proposal.html',
+ form.save()
+ else:
+ return render(request, 'fossee_manim/send_proposal.html',
{'form': form, 'categories': categories})
return redirect('/proposal_status/')
else:
@@ -406,7 +402,7 @@ def search(request):
if request.method == 'POST':
word = request.POST.get('sbox')
anime_list = AnimationStats.objects.filter(
- Q(animation__title__contains=word) | Q(animation__description__contains=word)
+ Q(animation__title__contains=word) | Q(animation__outline__contains=word)
| Q(animation__category__name__contains=word), animation__status='released')
return render(request, 'fossee_manim/search_results.html',