Merge branch 'master' of /srv/andis

This commit is contained in:
root
2020-09-29 05:25:08 +00:00
6 changed files with 68 additions and 41 deletions

View File

@@ -32,10 +32,12 @@ class ep_api():
self.get_epc()
text = self.epc.getHTML(padID=self.group["groupID"] + "$" + padID)["html"]
return text
def setPadHTML(self, padID, html):
self.get_epc()
text=self.epc.setHTML(padID=self.group["groupID"] + "$" + padID, html=html)
self.epc.setHTML(padID=self.group["groupID"] + "$" + padID, html=html)
return html
def checkPadExists(self, padID=None):
print(self.epc.listPads(groupID=self.group["groupID"]))
if not padID:

View File

@@ -19,13 +19,13 @@ def add_ep_cookie(request, response):
path="/",
)
return response
response.set_cookie(
"sessionID",
ep_sessid,
expires=expires,
domain=".2020.fet.at",
path="/"
)
#response.set_cookie(
# "sessionID",
# ep_sessid,
# expires=expires,
# domain=".2020.fet.at",
# path="/"
#)
response.set_cookie(
"sessionID",
ep_sessid,

View File

@@ -11,6 +11,11 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
import environ
env = environ.Env(
# set casting, default value
DEBUG=(bool, True)
)
# Prints and logs are written to console
# TODO: Change before release
@@ -37,13 +42,17 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env('DEBUG')
if DEBUG:
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'r37-i7l)vrduzz2-gira+z#u!p!di9#f+%s*5-bb($hg)55@ns'
else:
SECRET_KEY = env('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['uat1.2020.fet.at', '127.0.0.1']
ALLOWED_HOSTS = ["127.0.0.1", "localhost"]
DATA_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024 * 1024
# Application definition

View File

@@ -108,11 +108,10 @@ class Post(models.Model):
@agenda_html.setter
def agenda_html(self, value):
request_logger.info("Accessing etherpad ...")
h=ep.setPadHTML(self.agenda_key,value)
ep.setPadHTML(self.agenda_key, value)
request_logger.info("set etherpad!")
return value
@property
def get_tagnames(self):
return ["#%s" % t for t in self.tags.names()]
@@ -156,16 +155,9 @@ class Post(models.Model):
if not self.public_date:
self.public_date = timezone.now()
if (self.id is None) and (not self.slug):
if not self.slug:
self.slug = slugify(self.public_date.date()) + "-" + slugify(self.title)
if self.has_agenda:
self.agenda_key = ep.createPadifNotExists(self.slug + "-agenda")
if self.has_protocol:
self.protocol_key = ep.createPadifNotExists(self.slug + "-protocol")
request_logger.info(self.post_type)
super().save(*args, **kwargs)
self.tags.set(
@@ -179,6 +171,7 @@ class Post(models.Model):
class PostSerializer(serializers.HyperlinkedModelSerializer):
agenda_html = serializers.CharField()
class Meta:
model = Post
fields = [
@@ -255,31 +248,54 @@ class FetMeeting(Event):
verbose_name = "Fet Sitzung"
verbose_name_plural = "Fet Sitzungen"
def __get_slug(self):
self.slug = slugify(self.event_start.date()) + "-" + slugify("Fachschaftssitzung")
if Post.objects.filter(slug=self.slug).exists():
if Post.objects.get(slug=self.slug).id != self.id:
raise ValidationError(
_('Es existiert bereits eine Sitzung mit demselben Datum.')
)
def __get_agenda_key(self):
try:
self.agenda_key = ep.createPadifNotExists(self.slug + "-agenda")
except Exception as e:
raise ValidationError(
_('Die Agenda konnte nicht erstellt werden. Error: %(error)s'),
params={'error': str(e)},
)
def __get_protocol_key(self):
try:
self.protocol_key = ep.createPadifNotExists(self.slug + "-protocol")
except Exception as e:
raise ValidationError(
_('Das Protokoll konnte nicht erstellt werden. Error: %(error)s'),
params={'error': str(e)},
)
def clean(self):
if self.event_start is None:
raise ValidationError(_('Das Datum des Events fehlt.'))
elif (self.event_end) and (self.event_end < self.event_start):
raise ValidationError(_('Das Ende des Events liegt vor dem Beginn.'))
slug = slugify(self.event_start.date()) + "-" + slugify("Fachschaftssitzung")
if not self.slug:
self.__get_slug()
if Post.objects.filter(slug=slug).exists():
if Post.objects.get(slug=slug).id != self.id:
raise ValidationError(_('Es existiert bereits eine Sitzung mit demselben Datum.'))
if self.has_agenda:
self.__get_agenda_key()
if self.has_protocol:
self.__get_protocol_key()
def save(self, *args, **kwargs):
self.title = "Fachschaftssitzung"
if not self.slug:
self.slug = slugify(self.event_start.date()) + "-" + slugify(self.title)
self.body = "TODO: Agenda + Protokoll Link"
# TODO
# self.image
# TODO
# self.protocol_key
# self.agenda_key
if not self.post_type:
self.post_type = 'F'

View File

@@ -8,4 +8,4 @@ docutils==0.16
easy-thumbnails==2.7.0
etherpad-lite==0.5
django-filter
ldap3
ldap3django-environ