diff options
-rw-r--r-- | fossee_anime/settings.py | 2 | ||||
-rw-r--r-- | fossee_manim/forms.py | 77 | ||||
-rw-r--r-- | fossee_manim/models.py | 19 | ||||
-rw-r--r-- | fossee_manim/templates/fossee_manim/edit_proposal.html | 222 | ||||
-rw-r--r-- | fossee_manim/templates/fossee_manim/proposal_status.html | 24 | ||||
-rw-r--r-- | fossee_manim/views.py | 6 |
6 files changed, 225 insertions, 125 deletions
diff --git a/fossee_anime/settings.py b/fossee_anime/settings.py index 8b5f93a..82265ba 100644 --- a/fossee_anime/settings.py +++ b/fossee_anime/settings.py @@ -49,7 +49,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'taggit', - 'simple_history' + 'simple_history', ] MIDDLEWARE_CLASSES = [ diff --git a/fossee_manim/forms.py b/fossee_manim/forms.py index af2b96e..8b7eada 100644 --- a/fossee_manim/forms.py +++ b/fossee_manim/forms.py @@ -261,12 +261,87 @@ class AnimationProposal(forms.ModelForm): 'any other related information') } - class Meta: model = Animation + widgets = { + 'sketch': forms.FileInput(), + } fields = ['category', 'subcategory', 'title', 'outline', 'tags'] +class AnimationProposal_edit(forms.ModelForm): + """Animation form """ + required_css_class = 'required' + errorlist_css_class = 'errorlist' + + def __init__(self, *args, **kwargs): + super(AnimationProposal_edit, self).__init__(*args, **kwargs) + self.fields['subcategory'].widget.attrs['placeholder'] = 'Eg: Quantum Mechanics, Topology' + # self.fields['outline'].widget.attrs['placeholder'] = 'NOTE: Do\ + # add info about prerequisites (if any), possible textbooks and \ + # any other related information' + self.fields['outline'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('NOTE: Do add info about prerequisites (if any), possible textbooks and ' + 'any other related information') + } + self.fields['concepts'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Which concept(s) do you want to animate?' + 'Example: Animation of how data flows in Ring Topology') + } + self.fields['audience'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Who would be the target audience for your video?\n' + 'Example: High School Students, Mechanical Engineers, etc.') + } + + self.fields['reference'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Please try to be as specific as possible. For example,\n' + 'Book used: Linear Algebra.\n' + 'Author: Kenneth Hoffman, Ray Kunze\n' + 'Edition: Second\n' + 'Chapter: 2 ; Page: 40') + } + self.fields['tools'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('What all tools would you be using for animation?\n' + 'Example: manim, blender, mayavi, mathbox, etc') + } + self.fields['detaled_description'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Give a detailed description of your animation') + } + self.fields['link'].widget.attrs = { + 'id': 'custom_editor', + 'rows': 10, + 'cols': 50, + 'placeholder': ('Along with the video you will have to submit the source code github link below.\n') + } + self.fields['sketch'].label = "Sketch(.jpeg/.jpg only)" + + class Meta: + model = Animation + widgets = { + 'sketch': forms.FileInput(), + } + fields = ['category', 'subcategory', 'title', 'outline', 'tags', 'concepts', 'audience', 'reference', 'tools', + 'detaled_description', 'link', 'sketch'] + + class CommentForm(forms.ModelForm): """ """ diff --git a/fossee_manim/models.py b/fossee_manim/models.py index a6f68c2..f400818 100644 --- a/fossee_manim/models.py +++ b/fossee_manim/models.py @@ -115,6 +115,13 @@ def validate_file_extension(value): if not ext.lower() in valid_extensions: raise ValidationError(u'Unsupported file extension.') +def validate_img_extension(value): + import os + from django.core.exceptions import ValidationError + ext = os.path.splitext(value.name)[1] # [0] returns path+filename + valid_extensions = ['.jpg','.jpeg','.png'] + if not ext.lower() in valid_extensions: + raise ValidationError(u'Unsupported file extension.') class Profile(models.Model): """Profile for users(instructors and coordinators)""" @@ -172,19 +179,27 @@ class Animation(models.Model): reviewer = models.ForeignKey(User, null=True, on_delete=models.CASCADE, related_name="%(app_label)s_%(class)s_related") outline = models.TextField() - # concepts = models.TextField() - # audience=models.TextField() status = models.CharField(max_length=255, choices=status) 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() + # modifications + concepts=models.TextField(null=True,blank=True) + audience=models.TextField(null=True,blank=True) + reference=models.TextField(null=True,blank=True) + tools=models.TextField(null=True,blank=True) + detaled_description=models.TextField(null=True,blank=True) + link=models.CharField(max_length=255, blank=True) + sketch=models.ImageField(null=True, blank=True, upload_to=attachments, validators=[validate_img_extension]) def __str__(self): return u"{0} | {1}".format(self.title, self.status) + + class Comment(models.Model): comment = models.TextField() commentor = models.ForeignKey(User, on_delete=models.CASCADE) diff --git a/fossee_manim/templates/fossee_manim/edit_proposal.html b/fossee_manim/templates/fossee_manim/edit_proposal.html index 8543014..49bbfd0 100644 --- a/fossee_manim/templates/fossee_manim/edit_proposal.html +++ b/fossee_manim/templates/fossee_manim/edit_proposal.html @@ -1,131 +1,137 @@ {% extends 'fossee_manim/base.html' %} {% block title %} -Edit Proposal + Edit Proposal {% endblock %} {% block content %} -<script type="text/javascript"> - var url = window.location.href.split('/').pop(); -</script> -<br> -<div class="container"> - {% if messages %} - <ul class="messages"> - {% for message in messages %} - <div class="alert alert-{{ message.tags }}"> - <li {% if message.tags %} class="{{ message.tags }}" {% endif %}> {{ message }} - </li> - </div> - {% endfor %} - </ul> - {% endif %} + <script type="text/javascript"> + var url = window.location.href.split('/').pop(); + </script> + <br> + <div class="container"> + {% if messages %} + <ul class="messages"> + {% for message in messages %} + <div class="alert alert-{{ message.tags }}"> + <li {% if message.tags %} class="{{ message.tags }}" {% endif %}> {{ message }} + </li> + </div> + {% endfor %} + </ul> + {% endif %} - <form method="POST"> - {% csrf_token %} + <form method="POST"> + {% csrf_token %} - <table class="table table-bordered"> - {{ proposal_form.as_table }} - </table> + <table class="table table-bordered"> + <tr><td colspan="2"><center>PROPOSAL DETAILS</center></td></tr> + {{ proposal_form.as_table }} + </table> - <br> - <button class="btn btn-primary pull-right" type="submit" id="btnblue">Save</button> - <br> - </form> - <br> + <br> + <button class="btn btn-primary pull-right" type="submit" id="btnblue">Save</button> + <br> + </form> + <br> - {% if proposal_form.instance.status == 'changes' and request.user.profile.position == 'contributor' %} - <form method="POST" action="{% url 'upload_animation' proposal_form.instance.id %}" enctype="multipart/form-data"> - {% csrf_token %} - <label class="btn btn-info"> - {{ upload_form }} - <button class="btn btn-success" type="submit">Upload</button> - {{ msg }} - </label> - </form> - {% elif proposal_form.instance.status == 'pending' and request.user.profile.position == 'contributor' %} - <h3>Awaiting Reviewer's Moderation </h3> - <h6>Further details regarding the second stage of Proposal will be shared with you over the email shortly</h6> + {% if proposal_form.instance.status == 'changes' and request.user.profile.position == 'contributor' %} + <form method="POST" action="{% url 'upload_animation' proposal_form.instance.id %}" + enctype="multipart/form-data"> + {% csrf_token %} + <label class="btn btn-info"> + {{ upload_form }} + <button class="btn btn-success" type="submit">Upload</button> + {{ msg }} + </label> + </form> + {% elif proposal_form.instance.status == 'pending' and request.user.profile.position == 'contributor' %} + <h3>Awaiting Reviewer's Moderation </h3> + <h6>Further details regarding the second stage of Proposal will be shared with you over the email + shortly</h6> - {% else %} - <video width="100%" height="100%" controls> - <source src="{{video.0.video_path.url}}" type="video/mp4"> - </video> - {% endif %} + {% else %} + <video width="100%" height="100%" controls> + <source src="{{ video.0.video_path.url }}" type="video/mp4"> + </video> + {% endif %} - <br><br> - {% if request.user.profile.position == 'reviewer' %} - <form method="POST"> - {% csrf_token %} - <div class="form-group"> - <div class="row"> - <button class="btn btn-success pull-left" type="submit" name="release" value="1">Approve</button> - <button class="btn btn-danger pull-left" type="submit" name="rejected" value="2" - style="margin-left: 1%">Reject</button> - <button class="btn btn-info pull-left" type="submit" name="proposal_form" value="3" style="margin-left: 1%">Send - Proposal 2 Form</button> - </div> - </div> - </form> - {% endif %} - <br><br> + <br><br> + {% if request.user.profile.position == 'reviewer' %} + <form method="POST"> + {% csrf_token %} + <div class="form-group"> + <div class="row"> + <button class="btn btn-success pull-left" type="submit" name="release" value="1">Approve + </button> + <button class="btn btn-danger pull-left" type="submit" name="rejected" value="2" + style="margin-left: 1%">Reject + </button> + {# <button class="btn btn-info pull-left" type="submit" name="proposal_form" value="3" style="margin-left: 1%">Send#} + {# Proposal 2 Form</button>#} + </div> + </div> + </form> + {% endif %} + <br><br> - <h2>Comments</h2> - <div> - <form method="POST"> - <br> - {% csrf_token %} - {{ comment_form.as_p }} - <button type="submit" class="btn btn-default">Post</button> - </form> + <h2>Comments</h2> + <div> + <form method="POST"> + <br> + {% csrf_token %} + {{ comment_form.as_p }} + <button type="submit" class="btn btn-default">Post</button> + </form> - </div> - <hr style="background-color: #fff; + </div> + <hr style="background-color: #fff; border-top: 5px double #8c8b8b;"> - <table> - {% for comment in comments %} - <tbody> - <tr> - <td> - <h5>{{ comment.commentor.profile.user.get_full_name }} | {{ comment.created_date | date }}</h5> - <h6 style="background-color: #ecf0f1; padding:10px;">{{ comment.comment }}</h6> - <hr style="border-top: 0.5px solid #8c8b8b;"> - </td> - </tr> - </tbody> - {% endfor %} - </table> + <table> + {% for comment in comments %} + <tbody> + <tr> + <td> + <h5>{{ comment.commentor.profile.user.get_full_name }} | {{ comment.created_date | date }}</h5> + <h6 style="background-color: #ecf0f1; padding:10px;">{{ comment.comment }}</h6> + <hr style="border-top: 0.5px solid #8c8b8b;"> + </td> + </tr> + </tbody> + {% endfor %} + </table> - <br><br> -</div> + <br><br> + </div> -<!-- Page Navigation --> -<div class="container"> - <div class="Page-Nav" align="center"> - <nav aria-label="Page navigation"> - <ul class="pagination pagination-sm"> - <li class="page-item"> - {% if comments.has_previous %} - <a class="page-link" tabindex="-1" href="?page={{ comments.previous_page_number }}">Previous</a> - {% endif %} - </li> - <li class="page-item"> + <!-- Page Navigation --> + <div class="container"> + <div class="Page-Nav" align="center"> + <nav aria-label="Page navigation"> + <ul class="pagination pagination-sm"> + <li class="page-item"> + {% if comments.has_previous %} + <a class="page-link" tabindex="-1" + href="?page={{ comments.previous_page_number }}">Previous</a> + {% endif %} + </li> + <li class="page-item"> <span class="current"> Page {{ comments.number }} of {{ comments.paginator.num_pages }} </span> - </li> - <li class="page-item"> - {% if comments.has_next %} - <a class="page-link" href="?page={{ comments.next_page_number }}">Next - </a> - {% endif %} - </li> - </ul> - </nav> - </div> - <br> -</div> + </li> + <li class="page-item"> + {% if comments.has_next %} + <a class="page-link" href="?page={{ comments.next_page_number }}">Next + </a> + {% endif %} + </li> + </ul> + </nav> + </div> + <br> + </div> -</div> + </div> {% endblock %}
\ No newline at end of file diff --git a/fossee_manim/templates/fossee_manim/proposal_status.html b/fossee_manim/templates/fossee_manim/proposal_status.html index 19a780d..fa28e87 100644 --- a/fossee_manim/templates/fossee_manim/proposal_status.html +++ b/fossee_manim/templates/fossee_manim/proposal_status.html @@ -55,7 +55,6 @@ <th>Created Date</th> {% if request.user.profile.position == 'reviewer' %} <th>Contributor Name</th> - {# <th>Mail Status</th>#} {% endif %} </tr> </thead> @@ -71,15 +70,20 @@ <td><span class="text-info">{{ an.status }}</span></td> {% endif %} <td><span class="badge">{{ an.created }}</span></td> - {% if request.user.profile.position == 'reviewer' %} - <td>{{ an.contributor.get_full_name }}</td> - {# <td>{{ an.contributor.get_full_name }}</td>#} - {% endif %} - <td><a href="{% url 'edit_proposal' an.id %}"> - <button type="button" class="btn btn-info" - id="btnblue">Edit - </button> - </a></td> + <td> + {% if request.user.profile.position == 'reviewer' %} + {{ an.contributor.get_full_name }} + {% endif %} + </td> + <td> + {% if an.status == 'released' or request.user.profile.position == 'reviewer'%} + <a href="{% url 'edit_proposal' an.id %}"> + <button type="button" class="btn btn-info" + id="btnblue">Edit + </button> + </a> + {% endif %} + </td> {% if request.user.profile.position == 'reviewer' %} <td><a href="{% url 'delete_proposal' an.id %}"> <button type="button" class="btn btn-info" id="btnred">Delete</button> diff --git a/fossee_manim/views.py b/fossee_manim/views.py index 68d2c84..59eac34 100644 --- a/fossee_manim/views.py +++ b/fossee_manim/views.py @@ -2,7 +2,7 @@ from os import listdir, path, sep, makedirs, remove from .forms import ( UserRegistrationForm, UserLoginForm, ProfileForm, AnimationProposal, - CommentForm, UploadAnimationForm + CommentForm, UploadAnimationForm,AnimationProposal_edit ) from .models import ( Profile, User, AnimationStats, @@ -464,7 +464,7 @@ def edit_proposal(request, proposal_id=None): if is_email_checked(user) and user.is_authenticated(): comment_form = CommentForm() proposal = Animation.objects.get(id=proposal_id) - proposal_form = AnimationProposal(instance=proposal) + proposal_form = AnimationProposal_edit(instance=proposal) upload_form = UploadAnimationForm() categories = Category.objects.all() video = AnimationStats.objects.filter(animation=proposal_id) @@ -516,7 +516,7 @@ def edit_proposal(request, proposal_id=None): proposal=proposal) form_data.save() return redirect('/edit_proposal/{}'.format(proposal_id)) - proposal_form = AnimationProposal(request.POST, instance=proposal) + proposal_form = AnimationProposal_edit(request.POST, instance=proposal) if proposal_form.is_valid(): p_f = proposal_form.save(commit=False) p_f.contributor = user |