# Path: sshkm/models.py
# class Setting(models.Model):
#     name = models.CharField(max_length=100, unique=True)
#     value = models.TextField(null=True, blank=True)
# 
# Path: sshkm/forms.py
# class UserForm(forms.ModelForm):
#     password = forms.CharField(widget=forms.PasswordInput())
#     class Meta:
#         model = User
#         fields = ('password',)


from django.conf import settings
from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib import messages
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth.models import User
from django.contrib.auth.decorators import user_passes_test
from sshkm.models import Setting
from sshkm.forms import UserForm


@user_passes_test(lambda u:u.is_staff, login_url=None)
def SettingsList(request):
    users = User.objects.exclude(username='admin')
    try:
        privatekey = Setting.objects.get(name='MasterKeyPrivate')
        privatekey = privatekey.value[:50] + "\n...........\n" + privatekey.value[-50:]
    except:
        privatekey = ""

    try:

# Path: sshkm/models.py
# class Setting(models.Model):
#     name = models.CharField(max_length=100, unique=True)
#     value = models.TextField(null=True, blank=True)
# 
# Path: sshkm/forms.py
# class UserForm(forms.ModelForm):
#     password = forms.CharField(widget=forms.PasswordInput())
#     class Meta:
#         model = User
#         fields = ('password',)


# Path: sshkm/views/settings.py
from django.conf import settings
from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib import messages
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth.models import User
from django.contrib.auth.decorators import user_passes_test
from sshkm.models import Setting
from sshkm.forms import UserForm



@user_passes_test(lambda u:u.is_staff, login_url=None)
def SettingsList(request):
    users = User.objects.exclude(username='admin')
    try:
        privatekey = Setting.objects.get(name='MasterKeyPrivate')
        privatekey = privatekey.value[:50] + "\n...........\n" + privatekey.value[-50:]
    except:
        privatekey = ""

    try:

        publickey = Setting.objects.get(name='MasterKeyPublic')