From 36cb826aff8725cf2065ae828a94215d822d6a7c Mon Sep 17 00:00:00 2001 From: okalintu Date: Thu, 19 May 2016 02:12:41 +0300 Subject: [PATCH] more initial stuff --- readme.md | 51 ++++++++++++++++++++++++++-- requirements.txt | 3 ++ webapp/migrations/0001_initial.py | 56 +++++++++++++++++++++++++++++++ webapp/models.py | 31 ++++++++++++++++- 4 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 requirements.txt create mode 100644 webapp/migrations/0001_initial.py diff --git a/readme.md b/readme.md index 47f9b0b..e21ce2b 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,55 @@ +# SIKWEB 2.0 + +##Installation + +### Create virtualenvironment for python + virtualenv -p python3 virtualenv.sikweb +### clone This repo and enter it + +git clone +cd + +### Activate virtualenv (assuming we are on root of this repo and virtualenv is one step above) +`. ../virtualenv.sikweb/bin/activate` + +### install required python modules + +`pip install --upgrade pip` +`pip install -r requirements.txt` +### Install Mariadb and create necessary tables -Unsorted +`sudo apt-get install mariadb` -pip install --upgrade pip \ No newline at end of file +```SQL +CREATE USER 'sik'@'localhost' IDENTIFIED BY 'jokutmpassu'; +CREATE DATABASE sik DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; +GRANT ALL PRIVILEGES ON sik.* TO 'sik'@'localhost'; +CREATE DATABASE sik_test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; +GRANT ALL PRIVILEGES ON sik_test.* TO 'sik'@'localhost'; +``` + +## Configure django's settings + +cp sikweb/settings-sample.py sikweb/settings.py + +edit database settings from sikweb/settings.py according to what you used above. + +run `./manage.py migrate` + +you should be now have succesfully setup a devel version of sikweb 2.0 + +## Running + +### Activate virtualenv + +assuming we are on root of this repo and virtualenv is one step above: + +`. ../virtualenv.sikweb/bin/activate` + +### use runserver command +`./manage.py runserver` +`or./manage.py runserver 0.0.0.0:8000` if you need to connect from anywhere else than localhost \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c4906e7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +Django==1.9 +mysqlclient==1.3.7 +pytz==2016.4 diff --git a/webapp/migrations/0001_initial.py b/webapp/migrations/0001_initial.py new file mode 100644 index 0000000..47436e2 --- /dev/null +++ b/webapp/migrations/0001_initial.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2016-05-18 22:59 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Info', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('publish_time', models.DateTimeField(default=django.utils.timezone.now)), + ], + ), + migrations.CreateModel( + name='InfoTr', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('lang', models.CharField(default='fi', max_length=2)), + ('topic', models.CharField(max_length=255)), + ('content', models.TextField()), + ('translation_for', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='webapp.Info')), + ], + ), + migrations.CreateModel( + name='Tag', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('dummyname', models.CharField(max_length=127)), + ], + ), + migrations.CreateModel( + name='TagTr', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('lang', models.CharField(default='fi', max_length=2)), + ('name', models.CharField(max_length=127)), + ('translation_for', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='translations', to='webapp.Tag')), + ], + ), + migrations.AddField( + model_name='info', + name='tags', + field=models.ManyToManyField(related_name='news', to='webapp.Tag'), + ), + ] diff --git a/webapp/models.py b/webapp/models.py index 71a8362..6c68019 100644 --- a/webapp/models.py +++ b/webapp/models.py @@ -1,3 +1,32 @@ from django.db import models +from django.utils import timezone + +class Tag(models.Model): + dummyname = models.CharField(max_length=127) # ALWAYS USE TRANSLATED NAME!!! + +class TagTr(models.Model): + ''' + Model containing translations for tags + ''' + lang = models.CharField(max_length=2, default='fi') + name = models.CharField(max_length=127) + translation_for = models.ForeignKey('Tag', related_name='translations') + +class Info(models.Model): + ''' + model containing something showing on some info feed + ''' + publish_time = models.DateTimeField(default=timezone.now) + #published_by = models.Foreignkey(User) #<-- TODO create usermodel + tags = models.ManyToManyField(Tag,related_name="news") + +class InfoTr(models.Model): + ''' + Model containing translations for news + ''' + lang = models.CharField(max_length=2, default='fi') + + topic = models.CharField(max_length=255) + content = models.TextField() + translation_for = models.ForeignKey('Info', related_name='translations') -# Create your models here.