Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Newman committed Aug 24, 2016
2 parents 51850a3 + 1d929d2 commit d27d197
Show file tree
Hide file tree
Showing 15 changed files with 273 additions and 132 deletions.
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[run]
source = formly
omit = formly/tests/*,formly/admin.py
branch = 1

[report]
omit = formly/tests/*,formly/admin.py
21 changes: 14 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
sudo: false
language: python

python:
- 2.7

- "2.7"
- "3.4"
- "3.5"
env:
- DJANGO=1.8
- DJANGO=1.10
- DJANGO=master
matrix:
exclude:
install:
- pip install flake8
- pip install -e .

- pip install tox coveralls
script:
- flake8 .
- tox -e py${TRAVIS_PYTHON_VERSION//[.]/}-$DJANGO
after_success:
- coveralls
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
all: init docs test

init:
python setup.py develop
pip install detox coverage mkdocs

test:
coverage erase
detox
coverage html

docs:
mkdocs build

.PHONY: docs
48 changes: 48 additions & 0 deletions checkmigrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python
import os
import sys

import django

from django.conf import settings


DEFAULT_SETTINGS = dict(
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sites",
"formly",
"formly.tests"
],
MIDDLEWARE_CLASSES=[],
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
}
},
SITE_ID=1,
ROOT_URLCONF="formly.tests.urls",
SECRET_KEY="notasecret",
)


def check_migrations():
if not settings.configured:
settings.configure(**DEFAULT_SETTINGS)

django.setup()

parent = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, parent)

django.core.management.call_command(
"makemigrations",
"formly",
check=True,
dry_run=True,
)

if __name__ == "__main__":
check_migrations()
2 changes: 1 addition & 1 deletion formly/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6"
__version__ = "0.7"
23 changes: 19 additions & 4 deletions formly/models.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from __future__ import unicode_literals

from django import forms
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models import Max
from django.template.defaultfilters import slugify
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible
from django.contrib.auth.models import User
from jsonfield import JSONField

from .forms import MultipleTextField, MultiTextWidget


@python_2_unicode_compatible
class Survey(models.Model):
name = models.CharField(max_length=255)
creator = models.ForeignKey(User, related_name="surveys")
Expand All @@ -23,7 +27,7 @@ def save(self, *args, **kwargs):
self.updated = timezone.now()
return super(Survey, self).save(*args, **kwargs)

def __unicode__(self):
def __str__(self):
return self.name

def get_absolute_url(self):
Expand Down Expand Up @@ -100,6 +104,7 @@ def publish(self):
self.save()


@python_2_unicode_compatible
class Page(models.Model):
survey = models.ForeignKey(Survey, related_name="pages")
page_num = models.PositiveIntegerField(null=True, blank=True)
Expand All @@ -119,7 +124,7 @@ def save(self, *args, **kwargs):
self.page_num = (max_page.get("page_num__max") or 0) + 1
return super(Page, self).save(*args, **kwargs)

def __unicode__(self):
def __str__(self):
return self.label()

def label(self):
Expand Down Expand Up @@ -185,6 +190,7 @@ def is_last_page(self):
return self.next_page() is None


@python_2_unicode_compatible
class Field(models.Model):
TEXT_FIELD = 0
TEXT_AREA = 1
Expand Down Expand Up @@ -267,7 +273,7 @@ def move_down(self):
class Meta:
ordering = ["ordinal"]

def __unicode__(self):
def __str__(self):
return "%s of type %s on %s" % (
self.label, self.get_field_type_display(), self.survey
)
Expand Down Expand Up @@ -328,6 +334,7 @@ def form_field(self):
return field


@python_2_unicode_compatible
class FieldChoice(models.Model):
field = models.ForeignKey(Field, related_name="choices")
label = models.CharField(max_length=100)
Expand All @@ -345,10 +352,11 @@ def save(self, *args, **kwargs):
self.full_clean()
return super(FieldChoice, self).save(*args, **kwargs)

def __unicode__(self):
def __str__(self):
return self.label


@python_2_unicode_compatible
class SurveyResult(models.Model):
survey = models.ForeignKey(Survey, related_name="survey_results")
user = models.ForeignKey(User, related_name="survey_results")
Expand All @@ -357,7 +365,11 @@ class SurveyResult(models.Model):
def get_absolute_url(self):
return reverse("survey_edit", kwargs={"pk": self.pk, "page": 1})

def __str__(self):
return self.__repr__()


@python_2_unicode_compatible
class FieldResult(models.Model):
survey = models.ForeignKey(Survey, related_name="results") # Denorm
page = models.ForeignKey(Page, related_name="results") # Denorm
Expand All @@ -378,5 +390,8 @@ def answer_display(self):
return FieldChoice.objects.get(pk=int(val)).label
return val

def __str__(self):
return self.__repr__()

class Meta:
ordering = ["result", "question"]
Empty file added formly/tests/__init__.py
Empty file.
Empty file added formly/tests/models.py
Empty file.
7 changes: 7 additions & 0 deletions formly/tests/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.test import TestCase


class Tests(TestCase):

def setUp(self):
pass
6 changes: 6 additions & 0 deletions formly/tests/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.conf.urls import include


urlpatterns = [
(r"^", include("formly.urls")),
]
48 changes: 48 additions & 0 deletions makemigrations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python
import os
import sys

import django

from django.conf import settings


DEFAULT_SETTINGS = dict(
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sites",
"formly"
# "formly.tests",
],
MIDDLEWARE_CLASSES=[],
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
}
},
SITE_ID=1,
ROOT_URLCONF="formly.tests.urls",
SECRET_KEY="notasecret",
)


def run(*args):
if not settings.configured:
settings.configure(**DEFAULT_SETTINGS)

django.setup()

parent = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, parent)

django.core.management.call_command(
"makemigrations",
"formly",
*args
)


if __name__ == "__main__":
run(*sys.argv[1:])
54 changes: 54 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python
import os
import sys

import django

from django.conf import settings


DEFAULT_SETTINGS = dict(
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sites",
"formly",
"formly.tests"
],
MIDDLEWARE_CLASSES=[],
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
}
},
SITE_ID=1,
ROOT_URLCONF="formly.tests.urls",
SECRET_KEY="notasecret",
)


def runtests(*test_args):
if not settings.configured:
settings.configure(**DEFAULT_SETTINGS)

django.setup()

parent = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, parent)

try:
from django.test.runner import DiscoverRunner
runner_class = DiscoverRunner
test_args = ["formly.tests"]
except ImportError:
from django.test.simple import DjangoTestSuiteRunner
runner_class = DjangoTestSuiteRunner
test_args = ["tests"]

failures = runner_class(verbosity=1, interactive=True, failfast=False).run_tests(test_args)
sys.exit(failures)


if __name__ == "__main__":
runtests(*sys.argv[1:])
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1
Loading

0 comments on commit d27d197

Please sign in to comment.