Revert
This commit is contained in:
parent
36abf602e6
commit
7cac4157c6
8 changed files with 30 additions and 62 deletions
|
@ -405,10 +405,6 @@ DATABASES = {
|
||||||
"default": {
|
"default": {
|
||||||
"ENGINE": "django.db.backends.sqlite3",
|
"ENGINE": "django.db.backends.sqlite3",
|
||||||
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
|
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
|
||||||
'USER': 'dmoj',
|
|
||||||
'PASSWORD': 'YES',
|
|
||||||
'HOST': 'localhost',
|
|
||||||
'PORT': '',
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -665,11 +665,6 @@ urlpatterns = [
|
||||||
organization.EditOrganizationBlog.as_view(),
|
organization.EditOrganizationBlog.as_view(),
|
||||||
name="edit_organization_blog",
|
name="edit_organization_blog",
|
||||||
),
|
),
|
||||||
# url(
|
|
||||||
# r"^/blog/deleting$",
|
|
||||||
# organization.PendingBlogs.as_view(),
|
|
||||||
# name="organization_pending_blogs",
|
|
||||||
# ),
|
|
||||||
url(
|
url(
|
||||||
r"^/blog/pending$",
|
r"^/blog/pending$",
|
||||||
organization.PendingBlogs.as_view(),
|
organization.PendingBlogs.as_view(),
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
from email.policy import default
|
|
||||||
import re
|
import re
|
||||||
from tabnanny import verbose
|
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -98,7 +96,8 @@ class BlogPost(models.Model):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse("blog_post", args=(self.id , self.slug))
|
return reverse("blog_post", args=(self.id, self.slug))
|
||||||
|
|
||||||
def can_see(self, user):
|
def can_see(self, user):
|
||||||
if self.visible and self.publish_on <= timezone.now():
|
if self.visible and self.publish_on <= timezone.now():
|
||||||
if not self.is_organization_private:
|
if not self.is_organization_private:
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
from ast import Delete, arg
|
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.contrib.auth.models import User
|
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.core.cache.utils import make_template_fragment_key
|
from django.core.cache.utils import make_template_fragment_key
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
|
@ -19,7 +17,7 @@ from django.http import (
|
||||||
HttpResponseBadRequest,
|
HttpResponseBadRequest,
|
||||||
)
|
)
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.urls import reverse , reverse_lazy
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
@ -32,7 +30,6 @@ from django.views.generic import (
|
||||||
UpdateView,
|
UpdateView,
|
||||||
View,
|
View,
|
||||||
CreateView,
|
CreateView,
|
||||||
DeleteView,
|
|
||||||
)
|
)
|
||||||
from django.views.generic.detail import (
|
from django.views.generic.detail import (
|
||||||
SingleObjectMixin,
|
SingleObjectMixin,
|
||||||
|
@ -134,7 +131,7 @@ class OrganizationMixin(OrganizationBase):
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
self.organization_id = int(kwargs["pk"] )
|
self.organization_id = int(kwargs["pk"])
|
||||||
self.organization = get_object_or_404(Organization, id=self.organization_id)
|
self.organization = get_object_or_404(Organization, id=self.organization_id)
|
||||||
except Http404:
|
except Http404:
|
||||||
key = kwargs.get(self.slug_url_kwarg, None)
|
key = kwargs.get(self.slug_url_kwarg, None)
|
||||||
|
@ -933,8 +930,8 @@ class EditOrganizationContest(
|
||||||
problem_form.save()
|
problem_form.save()
|
||||||
for problem_form in problem_formset.deleted_objects:
|
for problem_form in problem_formset.deleted_objects:
|
||||||
problem_form.delete()
|
problem_form.delete()
|
||||||
super().post(request, *args, **kwargs)
|
return super().post(request, *args, **kwargs)
|
||||||
return HttpResponseRedirect(reverse("organization_contests", args=(self.organization_id,self.organization.slug) ))
|
|
||||||
self.object = self.contest
|
self.object = self.contest
|
||||||
return self.render_to_response(
|
return self.render_to_response(
|
||||||
self.get_context_data(
|
self.get_context_data(
|
||||||
|
@ -1039,7 +1036,7 @@ class EditOrganizationBlog(
|
||||||
MemberOrganizationMixin,
|
MemberOrganizationMixin,
|
||||||
UpdateView,
|
UpdateView,
|
||||||
):
|
):
|
||||||
template_name = "organization/blog/edit.html"
|
template_name = "organization/blog/add.html"
|
||||||
model = BlogPost
|
model = BlogPost
|
||||||
|
|
||||||
def get_form_class(self):
|
def get_form_class(self):
|
||||||
|
@ -1065,10 +1062,6 @@ class EditOrganizationBlog(
|
||||||
_("Not allowed to edit this blog"),
|
_("Not allowed to edit this blog"),
|
||||||
)
|
)
|
||||||
|
|
||||||
def delete_blog(self , request , *args , **kwargs):
|
|
||||||
self.blog_id = kwargs["blog_pk"]
|
|
||||||
BlogPost.objects.get(pk = self.blog_id).delete()
|
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
res = self.setup_blog(request, *args, **kwargs)
|
res = self.setup_blog(request, *args, **kwargs)
|
||||||
if res:
|
if res:
|
||||||
|
@ -1079,13 +1072,7 @@ class EditOrganizationBlog(
|
||||||
res = self.setup_blog(request, *args, **kwargs)
|
res = self.setup_blog(request, *args, **kwargs)
|
||||||
if res:
|
if res:
|
||||||
return res
|
return res
|
||||||
if request.POST['action'] == 'Delete':
|
return super().post(request, *args, **kwargs)
|
||||||
self.create_notification("Delete blog")
|
|
||||||
self.delete_blog(request , *args , **kwargs)
|
|
||||||
cur_url = reverse("organization_pending_blogs", args=(self.organization_id,self.organization.slug) )
|
|
||||||
return HttpResponseRedirect(cur_url)
|
|
||||||
else:
|
|
||||||
return super().post(request, *args, **kwargs)
|
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
return self.blog
|
return self.blog
|
||||||
|
@ -1093,36 +1080,32 @@ class EditOrganizationBlog(
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
return _("Edit blog %s") % self.object.title
|
return _("Edit blog %s") % self.object.title
|
||||||
|
|
||||||
def create_notification(self,action):
|
|
||||||
blog = BlogPost.objects.get(pk=self.blog_id)
|
|
||||||
link = reverse(
|
|
||||||
"edit_organization_blog",
|
|
||||||
args=[self.organization.id, self.organization.slug, self.blog_id],
|
|
||||||
)
|
|
||||||
html = (
|
|
||||||
f'<a href="{link}">{blog.title} - {self.organization.name}</a>'
|
|
||||||
)
|
|
||||||
post_authors = blog.authors.all()
|
|
||||||
posible_user = self.organization.admins.all() | post_authors
|
|
||||||
for user in posible_user:
|
|
||||||
if user.id == self.request.profile.id:
|
|
||||||
continue
|
|
||||||
notification = Notification(
|
|
||||||
owner=user,
|
|
||||||
author=self.request.profile,
|
|
||||||
category= action,
|
|
||||||
html_link=html,
|
|
||||||
)
|
|
||||||
notification.save()
|
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
with transaction.atomic(), revisions.create_revision():
|
with transaction.atomic(), revisions.create_revision():
|
||||||
res = super(EditOrganizationBlog, self).form_valid(form)
|
res = super(EditOrganizationBlog, self).form_valid(form)
|
||||||
revisions.set_comment(_("Edited from site"))
|
revisions.set_comment(_("Edited from site"))
|
||||||
revisions.set_user(self.request.user)
|
revisions.set_user(self.request.user)
|
||||||
self.create_notification("Edit blog")
|
|
||||||
|
link = reverse(
|
||||||
|
"edit_organization_blog",
|
||||||
|
args=[self.organization.id, self.organization.slug, self.object.id],
|
||||||
|
)
|
||||||
|
html = (
|
||||||
|
f'<a href="{link}">{self.object.title} - {self.organization.name}</a>'
|
||||||
|
)
|
||||||
|
for user in self.organization.admins.all():
|
||||||
|
if user.id == self.request.profile.id:
|
||||||
|
continue
|
||||||
|
notification = Notification(
|
||||||
|
owner=user,
|
||||||
|
author=self.request.profile,
|
||||||
|
category="Edit blog",
|
||||||
|
html_link=html,
|
||||||
|
)
|
||||||
|
notification.save()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
class PendingBlogs(
|
class PendingBlogs(
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
TitleMixin,
|
TitleMixin,
|
||||||
|
|
|
@ -290,19 +290,15 @@ class ProblemDetail(ProblemMixin, SolvedProblemMixin, CommentedDetailView):
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
print(self.request.LANGUAGE_CODE)
|
|
||||||
print(ProblemTranslation.objects.last().__dict__)
|
|
||||||
translation = self.object.translations.get(
|
translation = self.object.translations.get(
|
||||||
language=self.request.LANGUAGE_CODE
|
language=self.request.LANGUAGE_CODE
|
||||||
)
|
)
|
||||||
except ProblemTranslation.DoesNotExist:
|
except ProblemTranslation.DoesNotExist:
|
||||||
print('DNE')
|
|
||||||
context["title"] = self.object.name
|
context["title"] = self.object.name
|
||||||
context["language"] = settings.LANGUAGE_CODE
|
context["language"] = settings.LANGUAGE_CODE
|
||||||
context["description"] = self.object.description
|
context["description"] = self.object.description
|
||||||
context["translated"] = False
|
context["translated"] = False
|
||||||
else:
|
else:
|
||||||
print('E')
|
|
||||||
context["title"] = translation.name
|
context["title"] = translation.name
|
||||||
context["language"] = self.request.LANGUAGE_CODE
|
context["language"] = self.request.LANGUAGE_CODE
|
||||||
context["description"] = translation.description
|
context["description"] = translation.description
|
||||||
|
|
|
@ -21,6 +21,5 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<button type="submit" style="display: inline;" name="action" value="Save" >{{ _('Save') }} </button>
|
<button type="submit">{{ _('Save') }}</button>
|
||||||
<!-- <button type="submit" style="background-color: red; float: right;" name="action" value="Delete" > {{ _('Delete') }} </button> -->
|
|
||||||
</form>
|
</form>
|
|
@ -10,7 +10,7 @@
|
||||||
{% block users_media %}{% endblock %}
|
{% block users_media %}{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}z
|
{% block body %}
|
||||||
<div id="common-content">
|
<div id="common-content">
|
||||||
<div id="content-left" class="users">
|
<div id="content-left" class="users">
|
||||||
{% if page_obj and page_obj.num_pages > 1 %}
|
{% if page_obj and page_obj.num_pages > 1 %}
|
||||||
|
|
Loading…
Reference in a new issue