Skip to content

Commit

Permalink
major push of the app. Lots of updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lehnertz85 committed Dec 3, 2016
1 parent 7b6ad90 commit fd07a74
Show file tree
Hide file tree
Showing 63 changed files with 29,730 additions and 3,301 deletions.
9 changes: 9 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion dashboard/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from django.contrib import admin

# Register your models here.
from .models import Services, General, Drives

admin.site.register(Services)
admin.site.register(General)
admin.site.register(Drives)
9 changes: 9 additions & 0 deletions dashboard/fixtures/general.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"model": "dashboard.general",
"pk": 1,
"fields": {
"title": "Plex Dashboard - Manage your plex services"
}
}
]
152 changes: 152 additions & 0 deletions dashboard/fixtures/initialData.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
[
{
"model": "dashboard.services",
"pk": 1,
"fields": {
"app_name": "Settings",
"url": "settings.html",
"icon": "fa-cog",
"is_visible": true
}
},
{
"model": "dashboard.services",
"pk": 2,
"fields": {
"app_name": "RuTorrent",
"url": "https://github.com/Novik/ruTorrent",
"icon": "fa-globe",
"is_visible": true
}
},
{
"model": "dashboard.services",
"pk": 3,
"fields": {
"app_name": "NZBGet",
"url": "https://nzbget.net/",
"icon": "fa-download",
"is_visible": true
}
},
{
"model": "dashboard.services",
"pk": 4,
"fields": {
"app_name": "SABnzbd",
"url": "https://sabnzbd.org/",
"icon": "fa-download",
"is_visible": true
}
},
{
"model": "dashboard.services",
"pk": 5,
"fields": {
"app_name": "Pydio",
"url": "https://pydio.com/",
"icon": "fa-cloud",
"is_visible": true
}
},
{
"model": "dashboard.services",
"pk": 6,
"fields": {
"app_name": "Sonarr",
"url": "https://sonarr.tv/",
"icon": "fa-calendar",
"is_visible": false
}
},
{
"model": "dashboard.services",
"pk": 7,
"fields": {
"app_name": "SickBeard",
"url": "http://sickbeard.com/",
"icon": "fa-calendar",
"is_visible": false
}
},
{
"model": "dashboard.services",
"pk": 8,
"fields": {
"app_name": "CouchPotato",
"url": "https://couchpota.to/",
"icon": "fa-film",
"is_visible": false
}
},
{
"model": "dashboard.services",
"pk": 9,
"fields": {
"app_name": "Headphones",
"url": "https://github.com/rembo10/headphones",
"icon": "fa-headphones",
"is_visible": false
}
},
{
"model": "dashboard.services",
"pk": 10,
"fields": {
"app_name": "PlexRequests",
"url": "https://github.com/lokenx/plexrequests-meteor",
"icon": "fa-bullhorn",
"is_visible": false
}
},
{
"model": "dashboard.services",
"pk": 11,
"fields": {
"app_name": "PlexPy",
"url": "https://github.com/drzoidberg33/plexpy",
"icon": "fa-list",
"is_visible": false
}
},
{
"model": "dashboard.services",
"pk": 12,
"fields": {
"app_name": "Glances",
"url": "https:\/\/github.com\/nicolargo\/glances",
"icon": "fa-eye",
"is_visible": false
}
},
{
"model": "dashboard.services",
"pk": 13,
"fields": {
"app_name": "NZB Hydra",
"url": "https://github.com/theotherp/nzbhydra",
"icon": "fa-search",
"is_visible": false
}
},
{
"model": "dashboard.services",
"pk": 14,
"fields": {
"app_name": "Plex",
"url": "https://www.plex.tv/",
"icon": "fa-play-circle",
"is_visible": false
}
},
{
"model": "dashboard.services",
"pk": 15,
"fields": {
"app_name": "Deluge",
"url": "http://deluge-torrent.org/",
"icon": "fa-tint",
"is_visible": true
}
}
]
94 changes: 94 additions & 0 deletions dashboard/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import platform
import re

from django import forms
from django.forms import BaseModelFormSet
from django.utils.translation import ugettext_lazy as _
from psutil import disk_usage

from dashboard.models import Services, Drives


class BaseServicesFormModelFormSet(BaseModelFormSet):
def __init__(self, *args, **kwargs):
super(BaseServicesFormModelFormSet, self).__init__(*args, **kwargs)
# skip the Settings objects
self.queryset = Services.objects.exclude(id=1)


class ServicesForm(forms.ModelForm):
class Meta:
model = Services
fields = '__all__'
labels = {
'app_name': 'Service\'s Name:',
'icon': 'Select and icon:',
'url': 'Enter a URL:',
'is_visible': 'Do you want this application visible?'
}
required = {
'app_name': 'false',
'icon': 'false',
'url': 'false',
'is_visible': 'false',
}
max_length = {
'app_name': '512',
'icon': '512',
'url': '512',
}

widgets = {
'app_name': forms.TextInput(attrs={'class': 'validate', 'length': '512', 'placeholder': 'Enter the service\'s name:'}),
'icon': forms.TextInput(attrs={'class': 'validate', 'placeholder': ' Choose an icon'}),
'url': forms.TextInput(attrs={'class': 'validate', 'placeholder': 'What is the URL', 'length': '512'}),
}

def clean(self):
cleaned_data = super(ServicesForm, self).clean()
url = cleaned_data.get("url")

if 'http://' in url or 'https://' in url:
print('**** url is good to go')
else:
print("URL must contain http:// or https://")
raise forms.ValidationError(_('URL is incorrect'))

return cleaned_data


class DrivesForm(forms.ModelForm):
class Meta:
model = Drives
fields = '__all__'
labels = {
'letter': 'Drive:',
}
required = {
'letter': 'false',
}
max_length = {
'letter': '128',
}

widgets = {
'letter': forms.TextInput(
attrs={'class': 'validate', 'placeholder': ' Add a new Drive here', 'length': '128'}),
}

def clean(self):
cleaned_data = super(DrivesForm, self).clean()
letter = cleaned_data.get("letter")
print('*** Entering drive clean() ... %s' % letter)

if platform.system() == "Windows":
if not re.search(r"^[a-zA-Z]:\\$", letter):
raise forms.ValidationError(_('Drive letter must be <letter>:\\'))

try:
# Test to make sure the drive is present on the computer.
disk_usage(letter)
except:
raise forms.ValidationError(_('The drive could not be located'))

return cleaned_data
Loading

0 comments on commit fd07a74

Please sign in to comment.