diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..378d477 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,67 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ develop ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ develop ] + schedule: + - cron: '35 9 * * 6' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: [ 'javascript', 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/ossar-analysis.yml b/.github/workflows/ossar-analysis.yml new file mode 100644 index 0000000..513afd6 --- /dev/null +++ b/.github/workflows/ossar-analysis.yml @@ -0,0 +1,44 @@ +# This workflow integrates a collection of open source static analysis tools +# with GitHub code scanning. For documentation, or to provide feedback, visit +# https://github.com/github/ossar-action +name: OSSAR + +on: + push: + branches: [ develop ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ develop ] + schedule: + - cron: '26 13 * * 4' + +jobs: + OSSAR-Scan: + # OSSAR runs on windows-latest. + # ubuntu-latest and macos-latest support coming soon + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Ensure a compatible version of dotnet is installed. + # The [Microsoft Security Code Analysis CLI](https://aka.ms/mscadocs) is built with dotnet v3.1.201. + # A version greater than or equal to v3.1.201 of dotnet must be installed on the agent in order to run this action. + # GitHub hosted runners already have a compatible version of dotnet installed and this step may be skipped. + # For self-hosted runners, ensure dotnet version 3.1.201 or later is installed by including this action: + # - name: Install .NET + # uses: actions/setup-dotnet@v1 + # with: + # dotnet-version: '3.1.x' + + # Run open source static analysis tools + - name: Run OSSAR + uses: github/ossar-action@v1 + id: ossar + + # Upload results to the Security tab + - name: Upload OSSAR results + uses: github/codeql-action/upload-sarif@v1 + with: + sarif_file: ${{ steps.ossar.outputs.sarifFile }} diff --git a/.gitignore b/.gitignore index 620be43..1cfc82f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,36 +1,28 @@ -env -dump -config-bos-mint.yaml - -config-bos-mint.yaml - +.idea/ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] -*$py.class # C extensions *.so # Distribution / packaging .Python +env/ build/ develop-eggs/ dist/ downloads/ eggs/ -.eggs/ lib/ lib64/ parts/ sdist/ var/ -wheels/ -share/python-wheels/ *.egg-info/ .installed.cfg *.egg -MANIFEST +*.eggs # PyInstaller # Usually these files are written by a python script from a template @@ -45,17 +37,10 @@ pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ -.nox/ .coverage -.coverage.* .cache nosetests.xml coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ # Translations *.mo @@ -63,82 +48,15 @@ cover/ # Django stuff: *.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy # Sphinx documentation docs/_build/ +docs/html # PyBuilder -.pybuilder/ target/ -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ +# Vim temp files +*.swp -# Cython debug symbols -cython_debug/ +.ropeproject/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c210439..0e538d3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,6 +13,7 @@ gemnasium-python-dependency_scanning: stages: - test + - deploy test: stage: test @@ -20,3 +21,12 @@ test: - apt-get update -qy - apt-get install -y python3-dev python3-pip build-essential sqlite3 - pip3 install -r requirements.txt + +deployToDev: + stage: deploy + script: + - deployToDev + tags: + - cp1 + only: + - develop \ No newline at end of file diff --git a/README.md b/README.md index 2b1b2f4..59edcbe 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,36 @@ The project is a web based implementation of couch potato. +## Requirements +- Python 3 +- Virtualenv +- GCC +- Git +- MongoDB +- SQLite + +### Ubuntu 18+ +```bash +sudo apt-get update +sudo apt-get install python3 python3-venv python3-dev build-essential git mongodb libmysqlclient-dev -y +``` + ## Installation -```bash +```bash cd python-cp-gui python3 -m venv env source env/bin/activate pip3 install -r requirements.txt +# Configure config-bos-mint.yaml +cd couchpotato +cp example-config-bos-mint.yaml config-bos-mint.yaml ``` - - ### First Run -Modify config-bos-mint.yaml - ```bash +cd python-cp-gui source env/bin/activate cd couchpotato/scripts/ ./install.sh @@ -26,7 +40,9 @@ cd couchpotato/scripts/ This operation will clear all the existing users ## Usage + ```bash +cd python-cp-gui source env/bin/activate cd couchpotato python3 manage.py runserver 0.0.0.0:9010 @@ -41,4 +57,15 @@ openAPI 2.0 documentation is available at /swagger and /redoc ## Uninsallation Delete the python-cp-gui folder +## TLS +To run development cerver with TLS +python3 manage.py runsslserver 0.0.0.0:9020 + +To generate self signed certificates +sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt + +To run with certificates +python3 manage.py runsslserver 0.0.0.0:9020 --certificate tls.crt --key tls.key + + diff --git a/__version__ b/__version__ index 0ea3a94..0d91a54 100644 --- a/__version__ +++ b/__version__ @@ -1 +1 @@ -0.2.0 +0.3.0 diff --git a/couchpotato/calender/__init__.py b/couchpotato/calender/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/couchpotato/calender/admin.py b/couchpotato/calender/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/couchpotato/calender/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/couchpotato/calender/apps.py b/couchpotato/calender/apps.py new file mode 100644 index 0000000..811332c --- /dev/null +++ b/couchpotato/calender/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class CalenderConfig(AppConfig): + name = 'calender' diff --git a/couchpotato/calender/migrations/__init__.py b/couchpotato/calender/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/couchpotato/calender/models.py b/couchpotato/calender/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/couchpotato/calender/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/couchpotato/calender/templates/calender.html b/couchpotato/calender/templates/calender.html new file mode 100644 index 0000000..43c3aea --- /dev/null +++ b/couchpotato/calender/templates/calender.html @@ -0,0 +1,241 @@ +{% load static %} + + + + + + + + + + + + + + + + + + + + + + + + + + + {% include "navbar.html" %} + + +
+ +
loading...
+
+ +
+ Return to Home + Update +
+ + +
+ + + + + + diff --git a/couchpotato/game/tests.py b/couchpotato/calender/tests.py similarity index 100% rename from couchpotato/game/tests.py rename to couchpotato/calender/tests.py diff --git a/couchpotato/calender/urls.py b/couchpotato/calender/urls.py new file mode 100644 index 0000000..272ca0b --- /dev/null +++ b/couchpotato/calender/urls.py @@ -0,0 +1,16 @@ + +from django.urls import path ,re_path +from . import views +from django.conf.urls.static import static +from django.contrib.staticfiles.urls import staticfiles_urlpatterns +from django.views.static import serve +from django.urls import path, include + + +urlpatterns = [ + + path('',views.index,name= 'calender.html'), + +] + +urlpatterns += staticfiles_urlpatterns() \ No newline at end of file diff --git a/couchpotato/calender/views.py b/couchpotato/calender/views.py new file mode 100644 index 0000000..985a86b --- /dev/null +++ b/couchpotato/calender/views.py @@ -0,0 +1,19 @@ +from django.shortcuts import render + +# Create your views here. +from home.utilities import index_page_permitted + + +def index(request): + ''' + Decription: Render function to display calender + ''' + + try: + if index_page_permitted(request): + return render(request, "calender.html") + else: + return render(request, 'login.html') + except: + return render(request, '404.html') + \ No newline at end of file diff --git a/couchpotato/couchpotato/settings.py b/couchpotato/couchpotato/settings.py index cdef0d8..6cbf247 100644 --- a/couchpotato/couchpotato/settings.py +++ b/couchpotato/couchpotato/settings.py @@ -23,7 +23,8 @@ SECRET_KEY = '!fwkygc(zdgod8v934b9q(grdp7#(kd1vav4h)sdi6y_6p!oq6' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False +BOOL_SSLSERVER = True ALLOWED_HOSTS = ['*'] @@ -33,14 +34,17 @@ INSTALLED_APPS = [ 'home', 'game', + 'calender', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'drf_yasg', - 'rest_framework', + 'drf_yasg', + 'rest_framework', + 'sslserver', + #'rest_framework_swagger', ] @@ -135,7 +139,7 @@ STATIC_URL = '/static/' -if DEBUG: +if DEBUG or BOOL_SSLSERVER: STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static') ] diff --git a/couchpotato/couchpotato/urls.py b/couchpotato/couchpotato/urls.py index d61d32e..ccc13be 100644 --- a/couchpotato/couchpotato/urls.py +++ b/couchpotato/couchpotato/urls.py @@ -44,7 +44,10 @@ urlpatterns = [ path('', include('home.urls')), path('openapi/' , include('game.urls')), + path('calendar/', include('calender.urls')), path('admin/', admin.site.urls), + + re_path(r'^swagger(?P\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'), path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), diff --git a/couchpotato/cp_local.py b/couchpotato/cp_local.py index 09cf5be..6ce5489 100644 --- a/couchpotato/cp_local.py +++ b/couchpotato/cp_local.py @@ -1,3 +1,5 @@ + +from bos_incidents import factory, exceptions import _thread import time import numpy as np @@ -12,14 +14,12 @@ import yaml import logging - with open("config-bos-mint.yaml", "r") as f: config = yaml.safe_load(f) chainName = config["connection"]["use"] bosApis = config["bosApis"] potatoNames = config["potatoNames"] - # Create and configure logger # logging.basicConfig(filename="za.log", # format='%(asctime)s %(message)s', @@ -36,7 +36,6 @@ ppy = node.get_node() rpc = ppy.rpc - INCIDENT_CALLS = [ "create", "in_progress", @@ -52,6 +51,9 @@ normalizer = IncidentsNormalizer(chain=chainName) normalize = normalizer.normalize +# Incident Storage +storage = factory.get_incident_storage() + def substitution(teams, scheme): class Teams: @@ -684,21 +686,47 @@ def Push2bosMethod(self, incident, providerName): for k in ks: # for api in bosApis: print("inthread:", k) - api = bosApis[k] + api = list(bosApis[k].keys())[0] + acceptedProviderNames = list(bosApis[k].values())[0] # print(api) try: - requests.post(url=api, json=incident) + if providerName in acceptedProviderNames: + print("providername in acepted list:", providerName) + requests.post(url=api, json=incident) + else: + print("providername NOT in acepted list:", providerName) + except Exception as e: print(e) logger.warning(api + ": failed") time.sleep(self.delayBetweenBosPushes) + try: + # FIXME, remove copy() + storage.insert_incident(incident.copy()) + except exceptions.DuplicateIncidentException as e: + print(e) + # We merely pass here since we have the incident already + # alerting anyone won't do anything + # traceback.print_exc() + pass + print("thread finished") return def OpenProposalsCount(self): - openProposalsCount = rpc.get_proposed_transactions("1.2.1") + openProposalsCount = len(rpc.get_proposed_transactions("1.2.1")) return openProposalsCount, self.maxOpenProposals + def History(self, providerName): + collection = storage._get_collection(collection_name="incident") + historyGen = collection.find({"provider_info.name": { + "$eq": providerName}}) + + history = [] + for doc in historyGen: + history.append(doc) + history = history[::-1] + return history def Push2bosBetter(self, incident, providerNames): string = incident_to_string(incident) diff --git a/couchpotato/example-config-bos-mint.yaml b/couchpotato/example-config-bos-mint.yaml new file mode 100644 index 0000000..f3cec4f --- /dev/null +++ b/couchpotato/example-config-bos-mint.yaml @@ -0,0 +1,39 @@ +debug: FALSE +project_name: PYTHON COUCH POTATO +project_sub_name: The Python Couch Potato project +secret_key: THINK CLOCK SMOG FLAG SMACK TINKER FLUNK # enter any random string +advanced_features: True + +sql_database: "sqlite:///{cwd}/bookied-local.db" + +connection: + use: hercules # enter your desired chain + + hercules: + node: + - wss://hercules.peerplays.download/api + nobroadcast: False + num_retries: 1 + +allowed_assets: + - BTFUN + - PPY + - TEST + - BTF +potatoNames: + - cpx + - cpy + +bosApis: + - http://hercules.peerplays.download:8010/trigger: + - cpi + - cp2 + +token: + - + +token_telegram: '' + +telegram_chat_ids: + - "" + diff --git a/couchpotato/feed.py b/couchpotato/feed.py index 19b98a7..aad807c 100644 --- a/couchpotato/feed.py +++ b/couchpotato/feed.py @@ -258,6 +258,8 @@ def MatchingEvents(self, leagueIds): eventsFromFeed = eventsFromFeed + self.Past15(leagueId) eventsFromChain = self.cp.EventsAllSortedForApi() matchingEvents = [] + if isinstance(eventsFromChain, type(None)): + return matchingEvents for k in range(len(eventsFromChain)): # eventFromChain = eventsFromChain.iloc[k] eventFromChain = eventsFromChain[k] diff --git a/couchpotato/game/autofetch.py b/couchpotato/game/autofetch.py deleted file mode 100644 index 3c76d17..0000000 --- a/couchpotato/game/autofetch.py +++ /dev/null @@ -1,58 +0,0 @@ -# # Create your views here. -# from django.http import Http404 , JsonResponse -# from django.shortcuts import render -# import json -# import requests -# import pytz, datetime - -# def AutoCreateCouchPotato(request): - -# create_value=dict() - -# games = requests.get('https://www.thesportsdb.com/api/v1/json/1/all_leagues.php') -# json_data = games.json() -# league = json_data['leagues'] -# res = next((l for l in league if l['strLeague'] == 'NFL'), None) - -# print(res['idLeague']) -# create_value['league'] = res['strLeague'] -# create_value['idleague'] = res['idLeague'] - -# season = requests.get('https://www.thesportsdb.com/api/v1/json/1/search_all_seasons.php?id='+create_value['idleague']) -# json_season = season.json()['seasons'][-1] -# print(json_season) -# create_value['season'] = json_season['strSeason'] - -# comming_events = requests.get('https://www.thesportsdb.com/api/v1/json/1/eventsnextleague.php?id='+create_value['idleague']) -# json_events = comming_events.json()['events'] -# print(json_events) - -# create_value['comming_events'] = json_events - - -# return JsonResponse( create_value) - - - -# def post_create(request): -# question_id = request.POST.get("id") -# option_text = request.POST.get("optiontext") -# question_id = int(question_id) -# if question_id == 1: -# request.session['sport'] = option_text -# elif question_id == 2: -# request.session['eventGroup'] = option_text -# elif question_id == 3: -# request.session['home'] = option_text -# elif question_id == 4: -# request.session['away'] = option_text -# elif question_id == 5: -# request.session['startTime'] = option_text -# data = {"sport":request.session['sport'].strip() ,"eventGroup":request.session['eventGroup'].strip(),"home":request.session['home'].strip(),"away":request.session['away'].strip(),"startTime":request.session['startTime'].strip()} -# print("Data " , data) -# result = requests.post('http://s3.jemshid.com:8000/sports/api/game/', data = data) -# if(len(eval(result.text)) > 0): -# return JsonResponse({'success':'Posted','message':result.text}) -# else: -# JsonResponse({'success':'Error','message':result.text}) -# return JsonResponse({'success':True,'message':'success'}) diff --git a/couchpotato/game/urls.py b/couchpotato/game/urls.py index 97f39f0..5e58234 100644 --- a/couchpotato/game/urls.py +++ b/couchpotato/game/urls.py @@ -4,10 +4,8 @@ from django.conf import settings from django.conf.urls.static import static from django.contrib.staticfiles.urls import staticfiles_urlpatterns -from home.tests import Test from django.views.static import serve from game.restapi import CreatePotatos , UpdatePotatos -# from game.autofetch import AutoCreateCouchPotato from django.urls import path, include from rest_framework import routers, serializers, viewsets @@ -15,7 +13,6 @@ path('create_potato/',CreatePotatos.as_view(),name= 'create_potato'), path('update_potato/',UpdatePotatos.as_view(),name= 'update_potato'), - # path('auto_create_potato/',AutoCreateCouchPotato,name= 'auto_create_potato'), path('api-auth/', include('rest_framework.urls', namespace='rest_framework')), ] diff --git a/couchpotato/game/views.py b/couchpotato/game/views.py index e6143ab..dbdb1b2 100644 --- a/couchpotato/game/views.py +++ b/couchpotato/game/views.py @@ -13,6 +13,13 @@ def GetMatchingEvents(): listDist = fd.MatchingEventsAll() return listDist +def GetOpenProposalsCount(): + openproposals , maxproposals = cp.OpenProposalsCount() + return [openproposals ,maxproposals ] + +def GetHistory(providername): + return cp.History(providername) + def GetEvents(params={}): rDict = dict() sport = None diff --git a/couchpotato/home/events.json b/couchpotato/home/events.json deleted file mode 100644 index 173cb7d..0000000 --- a/couchpotato/home/events.json +++ /dev/null @@ -1,3 +0,0 @@ - - {"1": - {"id": "1.22.43", "name": [["en", "Miami Heat @ Los Angeles Lakers"]], "season": [["en", ""]], "start_time": "2020-10-10T06:30:00", "event_group_id": "1.21.15", "scores": [], "status": "finished"}, "2": {"id": "1.22.44", "name": [["en", "Los Angeles Lakers @ Miami Heat"]], "season": [["en", ""]], "start_time": "2020-10-12T05:00:00", "event_group_id": "1.21.15", "scores": [], "status": "in_progress"}, "3": {"id": "1.22.48", "name": [["en", "Utah Jazz @ Toronto Raptors"]], "season": [["en", ""]], "start_time": "2020-10-29T22:00:00", "event_group_id": "1.21.15", "scores": [], "status": "upcoming"}, "4": {"id": "1.22.49", "name": [["en", "Orlando Magic @ Oklahoma City Thunder"]], "season": [["en", ""]], "start_time": "2020-10-29T22:00:00", "event_group_id": "1.21.15", "scores": [], "status": "upcoming"}} diff --git a/couchpotato/home/questions.json b/couchpotato/home/questions.json deleted file mode 100644 index 7282912..0000000 --- a/couchpotato/home/questions.json +++ /dev/null @@ -1,24 +0,0 @@ - -[ - { - "list" : { "1":"Male","2":"Female" , "3":"Other"} , - "question":"Question No 1", - "islast": false, - "question_id":1 - }, - { - "list" : { "1":"2 Male ","2":"2 Female" , "3":"2 Other"} , - "question":"Question No 2", - "islast": false, - "question_id":2 - }, - - { - "list" : { "1":"3 Male ","2":"3 Female" , "3":"3 Other"} , - "question":"Question No 3", - "islast": true, - "question_id":3 - } - - -] \ No newline at end of file diff --git a/couchpotato/home/templates/admin.html b/couchpotato/home/templates/admin.html index d259186..8cae738 100644 --- a/couchpotato/home/templates/admin.html +++ b/couchpotato/home/templates/admin.html @@ -19,7 +19,7 @@
-

Application Settings

+

Application Settings


- - - - - - - - - - - - - Couch Potato - - - - - - {% include "navbar.html" %} - - - -
- -

- - -
- -

{{heading}}

- -
- - - {% for key, value in list.items %} - -
- {% endfor %} - - {% if islast %} - - -
- -
- - - - -
-
- -
- - {% endif %} - - - - -
- {% if question_id > 1 %} - - {% endif %} - - {% if not islast %} - - - - {% endif %} - - {% if islast %} - - - - - {% endif %} - - Return to Home - - - -
- - - -
- - - - - - - - - - - - - - - - - - - - - - diff --git a/couchpotato/home/templates/create_cp.html b/couchpotato/home/templates/create_cp.html index 9e560b1..7350169 100644 --- a/couchpotato/home/templates/create_cp.html +++ b/couchpotato/home/templates/create_cp.html @@ -17,11 +17,14 @@ Couch Potato @@ -34,7 +37,8 @@

- + +

Number of Open Proposals: {{ proposals.0 }} / {{ proposals.1 }}

@@ -45,7 +49,7 @@

Select Sport

- +
-

Home

+

Home Team


-

Away

+

Away Team


@@ -95,6 +99,12 @@

Start Time

+ +
+
+ +
+

@@ -172,17 +182,14 @@

Start Time

new_next_select_id = id + 1 if (id == 1 || id == 2){ - $('#3').html('') - $('#4').html('') + $('#3').html('') + $('#4').html('') } sport = $('.games').find("option:selected").text() groups = $('.groups').find("option:selected").text() home = $('.home').find("option:selected").text() away = $('.away').find("option:selected").text() - console.log(sport) - console.log(groups) - console.log(home) - console.log(away) + @@ -197,13 +204,11 @@

Start Time

}, function(data, status){ - console.log(data) - var obj = data.list - $('#'+new_next_select_id).html('') + var obj = data.list + $('#'+new_next_select_id).html('') if (data.list[1] != 'status'){ Object.keys(obj).forEach(function(key) { - console.log(key, obj[key]); - + $('#'+new_next_select_id).append("") }); } @@ -213,7 +218,44 @@

Start Time

}); - + function validate(){ + + var sport = $('.games').find("option:selected").val() + var groups = $('.groups').find("option:selected").val() + var home = $('.home').find("option:selected").val() + var away = $('.away').find("option:selected").val() + var date_val = $('#datetimepicker1 input').val() + + + if(parseInt(sport) === 999){ + $('#error_msg').html('Please select a sport') + return false + } + else if(parseInt(groups) === 999){ + $('#error_msg').html('Please select a league') + return false + } + else if(parseInt(home) === 999){ + $('#error_msg').html('Please select a home team') + return false + } + else if(parseInt(away) === 999){ + $('#error_msg').html('Please select a away team') + return false + } + else if(typeof date_val === 'undefined' || date_val === ""){ + $('#error_msg').html('Please select a date time') + return false + } + else{ + $('#error_msg').html('') + return true + } + + + + + } $("#create_submit").click(function(){ @@ -221,11 +263,13 @@

Start Time

var selectedtext = $("form input[type='radio']:checked").next('label:first').html() var next_num = parseInt($("form").attr("id")) + 1 + var date_val = $('#datetimepicker1 input').val() var d = new Date(date_val) question_id = 5 - - if (typeof date_val !== 'undefined' & date_val !== ""){ + + if (validate()){ + $.post("/post_create", { id: question_id, @@ -234,45 +278,19 @@

Start Time

csrfmiddlewaretoken: '{{ csrf_token }}' , }, function(data, status){ - alert(data.success) - window.location.href = '/' + if (data.success == 'Posted'){ + alert(data.message) + window.location.href = '/' + } + + + }); } }) - // $("#next").click(function(){ - - - // var selected = $("form input[type='radio']:checked"); - // var selectedtext = $("form input[type='radio']:checked").next('label:first').html() - - // var next_num = parseInt($("form").attr("id")) + 1 - // // console.log(selectedtext) - - // if (typeof selectedtext !== 'undefined'){ - // $.post("/post_create", - // { - // id: $("form").attr("id"), - // optionvalue: selected.val(), - // optiontext : selectedtext, - // csrfmiddlewaretoken: '{{ csrf_token }}' , - // }, - // function(data, status){ - // window.location.href = '/create/'+next_num - // }); - // } - - - // }); - - // $("#back").click(function(){ - - - // var next_num = parseInt($("form").attr("id")) - 1 - // window.location.href = '/create/'+next_num - - // }); + diff --git a/couchpotato/home/templates/history.html b/couchpotato/home/templates/history.html new file mode 100644 index 0000000..e53202f --- /dev/null +++ b/couchpotato/home/templates/history.html @@ -0,0 +1,231 @@ + + + + + Couch Potato + + + + + + + + + + + + + + {% include "navbar.html" %} + +
+
+ +

+

Number of Open Proposals: {{ proposals.0 }} / {{ proposals.1 }}

+ + + + +
+ + + + + + + + + + + + + + + + + + + + {% for a in data.items %} + + + + + + + + + + + + + + + + + + + + + + + + {% endfor %} + + + +
Start TimeSportEvent Group NameHomeAwayHome ScoreAway ScoreTimestampUnique StringId stringName
+ {{ a.1.id.start_time }} + + {{ a.1.id.sport }} + + {{ a.1.id.event_group_name }} + + {{ a.1.id.home }} + + {{ a.1.id.away }} + + {{ a.1.arguments.home_score }} + + {{ a.1.arguments.away_score }} + + {{ a.1.timestamp }} + + {{ a.1.unique_string }} + + {{ a.1.id_string }} + + {{ a.1.provider_info.name }} +
+ + + + + Return to Home + +
+ + +
+
+ + + + + + + + + + + + + + + + + + diff --git a/couchpotato/home/templates/index.html b/couchpotato/home/templates/index.html index ebf0fe1..d8c2051 100644 --- a/couchpotato/home/templates/index.html +++ b/couchpotato/home/templates/index.html @@ -12,6 +12,17 @@ + @@ -29,10 +40,30 @@

- + +
+
+
+ CREATE +
+
+ UPDATE +
+
+ +
+
+ HISTORY +
+
+ CALENDAR +
+
+
+ + + + diff --git a/couchpotato/home/templates/login.html b/couchpotato/home/templates/login.html index c38e352..572f187 100644 --- a/couchpotato/home/templates/login.html +++ b/couchpotato/home/templates/login.html @@ -18,12 +18,7 @@ - - - + @@ -52,8 +47,7 @@
- -
+
@@ -70,9 +64,7 @@
- {% if messages %} - - + {% if messages %} {% for message in messages %} {{message}} @@ -80,8 +72,7 @@ {% endfor %} - - {% endif %} + {% endif %} @@ -97,20 +88,7 @@
- +
@@ -122,29 +100,14 @@

...or login with:

- - + - + diff --git a/couchpotato/home/templates/navbar.html b/couchpotato/home/templates/navbar.html index d42b253..7d35aa5 100644 --- a/couchpotato/home/templates/navbar.html +++ b/couchpotato/home/templates/navbar.html @@ -4,9 +4,13 @@ .rounded-circle{ width: 40px; } + body{background-color: beige;} + nav{ + background-color: beige !important; + } -