From a8e1e8e87021a040209d2ce5d0e81459120b3bb1 Mon Sep 17 00:00:00 2001 From: Sounak Pradhan Date: Thu, 11 Jul 2019 10:42:02 +0530 Subject: [PATCH 1/3] Add comment admin --- gsoc/admin.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gsoc/admin.py b/gsoc/admin.py index d64aa90e..1833d196 100644 --- a/gsoc/admin.py +++ b/gsoc/admin.py @@ -1,6 +1,6 @@ from .models import (UserProfile, RegLink, UserDetails, Scheduler, PageNotification, AddUserLog, BlogPostDueDate, Builder, Timeline, ArticleReview, Event, SubOrgDetails, - GsocEndDate) + GsocEndDate, Comment) from .forms import (UserProfileForm, UserDetailsForm, RegLinkForm, BlogPostDueDateForm, EventForm, GsocEndDateForm) @@ -519,3 +519,13 @@ def has_add_permission(self, request, obj=None): admin.site.register(SubOrgDetails, SubOrgDetailsAdmin) + + +class CommentAdmin(admin.ModelAdmin): + list_display = ('username', 'article', 'content') + + def has_add_permission(self, request, obj=None): + return False + + +admin.site.register(Comment, CommentAdmin) From 9b0dc31ee5172225570f5bc94496ae034d04327e Mon Sep 17 00:00:00 2001 From: Sounak Pradhan Date: Thu, 11 Jul 2019 11:29:04 +0530 Subject: [PATCH 2/3] Add mentor for specific suborg application --- suborg/templates/application_list.html | 17 ++++++++++++----- suborg/urls.py | 2 +- suborg/views.py | 25 +++++++++++++++++-------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/suborg/templates/application_list.html b/suborg/templates/application_list.html index e3f5a21b..3b36b2c4 100644 --- a/suborg/templates/application_list.html +++ b/suborg/templates/application_list.html @@ -5,13 +5,20 @@

Select any of the applications to change

diff --git a/suborg/urls.py b/suborg/urls.py index 6564c44e..a79ae9b9 100644 --- a/suborg/urls.py +++ b/suborg/urls.py @@ -16,6 +16,6 @@ # name='reject_application'), ])), url('^mentor/', include([ - url('^add/', views.add_mentor, name='add_mentor') + url('^add/(?P[0-9]+)/', views.add_mentor, name='add_mentor') ])), ] diff --git a/suborg/views.py b/suborg/views.py index 5153640a..7a4ebd54 100644 --- a/suborg/views.py +++ b/suborg/views.py @@ -19,7 +19,7 @@ def is_suborg_admin(user): def home(request): - return redirect(reverse('suborg:register_suborg')) + return redirect(reverse('suborg:application_list')) @decorators.login_required @@ -108,9 +108,18 @@ def accept_application(request, application_id): # return redirect(reverse('admin:gsoc_suborgdetails_change', args=[application_id])) -@decorators.user_passes_test(is_suborg_admin) -def add_mentor(request): - profile = request.user.suborg_admin_profile() +@decorators.login_required +def add_mentor(request, application_id): + application = SubOrgDetails.objects.get(id=application_id) + + if not application.accepted: + messages.error(request, 'Application not accepted yet! Can not add mentors.') + return redirect(reverse('suborg:application_list')) + + if application.suborg_admin_email != request.user.email: + messages.error(request, 'You are not authorized to add mentors for this suborg.') + return redirect(reverse('suborg:application_list')) + MentorFormSet = modelformset_factory(RegLink, fields=('email', ), extra=4) if request.method == 'POST': @@ -118,8 +127,8 @@ def add_mentor(request): if formset.is_valid(): instances = formset.save(commit=False) for instance in instances: - instance.user_suborg = profile.suborg_full_name - instance.user_gsoc_year = profile.gsoc_year + instance.user_suborg = application.suborg + instance.user_gsoc_year = application.gsoc_year instance.user_role = 2 instance.save() else: @@ -127,8 +136,8 @@ def add_mentor(request): 'formset': formset, }) - formset = MentorFormSet(queryset=RegLink.objects.filter(user_gsoc_year=profile.gsoc_year, - user_suborg=profile.suborg_full_name, + formset = MentorFormSet(queryset=RegLink.objects.filter(user_gsoc_year=application.gsoc_year, + user_suborg=application.suborg, user_role=2)) return render(request, 'add_mentor.html', { From a1056c94bc7afef6deb4532534414b769b358781 Mon Sep 17 00:00:00 2001 From: Sounak Pradhan Date: Thu, 11 Jul 2019 11:31:29 +0530 Subject: [PATCH 3/3] Migrate db --- project.db | Bin 1519616 -> 1523712 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/project.db b/project.db index 589939fcc68ed977b9725fcc6a34fc8aefebe28e..38941d70de6dcb7f3026e5c10c05f0703ba94780 100644 GI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