Skip to content
Snippets Groups Projects
Commit 22d9b93b authored by Martin Schwenke's avatar Martin Schwenke
Browse files

adding app veranstaltung

including models
parent 856ac952
Branches vaMigration
No related tags found
No related merge requests found
Pipeline #41148 failed
...@@ -48,6 +48,7 @@ ALLOWED_HOSTS = ['oneup-02.cs.uni-potsdam.de', '.localhost', '[::1]', '127.0.0.1 ...@@ -48,6 +48,7 @@ ALLOWED_HOSTS = ['oneup-02.cs.uni-potsdam.de', '.localhost', '[::1]', '127.0.0.1
INSTALLED_APPS = [ INSTALLED_APPS = [
'articles.apps.ArticlesConfig', 'articles.apps.ArticlesConfig',
'veranstaltung.apps.VeranstaltungsConfig',
'rest_framework', 'rest_framework',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
......
...@@ -40,4 +40,5 @@ urlpatterns = [ ...@@ -40,4 +40,5 @@ urlpatterns = [
url(r'^redoc/$', SchemaView.with_ui('redoc', cache_timeout=0), name='schema-redoc'), url(r'^redoc/$', SchemaView.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('articles/', include('articles.urls')), path('articles/', include('articles.urls')),
path('veranstaltung/', include('veranstaltung.urls'))
] ]
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class VeranstaltungConfig(AppConfig):
name = 'veranstaltung'
from django.db import models
# Create your models here.
class Author(models.Model):
"""Model of a single author"""
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255)
mailAddress = models.CharField(max_length=255, unique=True)
def __str__(self):
return self.name
class Meta:
"""Definition of MySQL Table"""
db_table = "author"
class Event(models.Model):
"""Model of a single event, which is connected to a author and valued indicators"""
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255)
start_time = models.DateTimeField('start_time')
last_updated = models.DateTimeField('last_updated')
author = models.ManyToManyField(Author)
# valued_indicators = models.ManyToOneRel(ValuedIndicator, through='EventValuedIndicator')
def __str__(self):
return self.name
class Meta:
"""Definition of MySQL Table"""
db_table = "event"
class Feedback(models.Model):
"""Model of a single feedback, which is connected to valued indicators"""
id = models.AutoField(primary_key=True)
submit_time = models.DateTimeField('submit_time')
event = models.OneToOneField(Event, on_delete=models.CASCADE)
class Meta:
"""Definition of MySQL Table"""
db_table = "feedback"
class Indicator(models.Model):
"""Model of a single indicator"""
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255)
description = models.CharField(max_length=255)
is_public = models.BooleanField()
def __str__(self):
return self.name
class Meta:
"""Definition of MySQL Table"""
db_table = "indicator"
class ValuedIndicator(models.Model):
"""Model of a single valued indicator"""
id = models.AutoField(primary_key=True)
proposed = models.IntegerField(default=0)
actual = models.IntegerField(default=0)
indicators = models.ManyToManyField(Indicator)
feedback = models.ForeignKey(Feedback, on_delete=models.CASCADE)
class Meta:
"""Definition of MySQL Table"""
db_table = "valued_indicator"
from django.test import TestCase
# Create your tests here.
""" URLs for this module """
from django.urls import path
from articles import views
urlpatterns = [
path('author', views.AuthorList.as_view()), # GET
path('author', views.NewAuthor.as_view()), # POST -> add new Author
path('author/<int:pk>', views.AuthorDetail.as_view()), # GET
path('author/<int:pk>/events', views.EventsDetail.as_view()), # GET
path('event', views.EventList.as_view()), # GET
path('event', views.NewEvent.as_view()), # POST
path('feedback/<string:string>', views.FeedbackByAuthorMailAddress.as_view()), # GET
path('feedback', views.NewFeedback.as_view()), # POST
path('feedback/<int:pk>', views.FeedbackByID.as_view()), # GET
path('ical', views.UpdateListOfEvents.as_view()), # GET
path('newsfeed', views.UpdateListOfEvents.as_view()), # GET
# TODO: how to differ get and post?
]
from django.shortcuts import render
# Create your views here.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment