Skip to content

Commit

Permalink
Use preflibtools in addadataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Rey committed Oct 15, 2024
1 parent 193ec32 commit d573b6a
Show file tree
Hide file tree
Showing 20 changed files with 840 additions and 552 deletions.
4 changes: 2 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'preflib.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "preflib.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand All @@ -17,5 +17,5 @@ def main():
execute_from_command_line(sys.argv)


if __name__ == '__main__':
if __name__ == "__main__":
main()
74 changes: 36 additions & 38 deletions preflib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,79 +23,78 @@
# Application definition

INSTALLED_APPS = [
'preflibapp.apps.PreflibappConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_distill',
"preflibapp.apps.PreflibappConfig",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_distill",
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = 'preflib.urls'
ROOT_URLCONF = "preflib.urls"

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "templates")],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = 'preflib.wsgi.application'
WSGI_APPLICATION = "preflib.wsgi.application"


# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
}
DATABASES = {}


# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = "en-us"

TIME_ZONE = 'UTC'
TIME_ZONE = "UTC"

USE_I18N = True

Expand All @@ -104,12 +103,11 @@
USE_TZ = True


STATIC_URL = "/static/"

STATIC_URL = '/static/'

LOGIN_URL = '/login'
LOGIN_URL = "/login"

# Auto primary keys
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

from preflib.local_settings import *
13 changes: 7 additions & 6 deletions preflib/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import path, include
from django.conf.urls import handler400, handler403, handler404, handler500

handler400 = 'preflibapp.views.error_400_view'
handler403 = 'preflibapp.views.error_403_view'
handler404 = 'preflibapp.views.error_404_view'
handler500 = 'preflibapp.views.error_500_view'
handler400 = "preflibapp.views.error_400_view"
handler403 = "preflibapp.views.error_403_view"
handler404 = "preflibapp.views.error_404_view"
handler500 = "preflibapp.views.error_500_view"

urlpatterns = [
path('djangoadmin/', admin.site.urls),
path('', include('preflibapp.urls'))
path("djangoadmin/", admin.site.urls),
path("", include("preflibapp.urls")),
]
2 changes: 1 addition & 1 deletion preflib/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'preflib.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "preflib.settings")

application = get_wsgi_application()
2 changes: 1 addition & 1 deletion preflibapp/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
admin.site.register(Metadata)
admin.site.register(DataProperty)
admin.site.register(Paper)
admin.site.register(Log)
admin.site.register(Log)
2 changes: 1 addition & 1 deletion preflibapp/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class PreflibappConfig(AppConfig):
name = 'preflibapp'
name = "preflibapp"
39 changes: 18 additions & 21 deletions preflibapp/choices.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def find_choice_value(choices, key):
for (k, v) in choices:
for k, v in choices:
if k == key:
return v
return None
Expand All @@ -13,35 +13,32 @@ def is_choice(choices, choice):


DATATYPES = [
('soc', 'strict order complete'),
('soi', 'strict order incomplete'),
('toc', 'tie order complete'),
('toi', 'tie order incomplete'),
('cat', 'categorical'),
("soc", "strict order complete"),
("soi", "strict order incomplete"),
("toc", "tie order complete"),
("toi", "tie order incomplete"),
("cat", "categorical"),
# ('tog', 'tournament graph'),
# ('mjg', 'majority graph'),
# ('wmg', 'weighted majority graph'),
# ('pwg', 'pairwise graph'),
('wmd', 'weighted matching data'),
('dat', 'extra data file'),
('csv', 'comma-separated values')
("wmd", "weighted matching data"),
("dat", "extra data file"),
("csv", "comma-separated values"),
]

MODIFICATIONTYPES = [
('original', 'original'),
('induced', 'induced'),
('imbued', 'imbued'),
('synthetic', 'synthetic')
("original", "original"),
("induced", "induced"),
("imbued", "imbued"),
("synthetic", "synthetic"),
]

METADATACATEGORIES = [
('general', 'general properties'),
('preference', 'preference structure'),
('ballot', 'ballot structure'),
('aggregation', 'aggregtated structure')
("general", "general properties"),
("preference", "preference structure"),
("ballot", "ballot structure"),
("aggregation", "aggregtated structure"),
]

SEARCHWIDGETS = [
('ternary', 'ternary choices'),
('range', 'range')
]
SEARCHWIDGETS = [("ternary", "ternary choices"), ("range", "range")]
Loading

0 comments on commit d573b6a

Please sign in to comment.