Compare commits

...

3 Commits

Author SHA1 Message Date
PCoder e51af13a31 Change the str repr 2021-01-22 22:41:56 +05:30
PCoder c6f05889ff Modify admin template to include table wrap styles 2021-01-22 08:08:40 +05:30
PCoder ac139c8a99 Register UserHostingKey to admin site and add str repr 2021-01-21 20:46:12 +05:30
4 changed files with 42 additions and 2 deletions

View File

@ -3,6 +3,7 @@ from cms.admin.placeholderadmin import PlaceholderAdminMixin
from cms.extensions import PageExtensionAdmin
from .cms_models import CMSIntegration, CMSFaviconExtension
from .models import VMPricing, VMTemplate
from hosting.models import UserHostingKey
class CMSIntegrationAdmin(PlaceholderAdminMixin, admin.ModelAdmin):
@ -17,3 +18,4 @@ admin.site.register(CMSIntegration, CMSIntegrationAdmin)
admin.site.register(CMSFaviconExtension, CMSFaviconExtensionAdmin)
admin.site.register(VMPricing)
admin.site.register(VMTemplate)
admin.site.register(UserHostingKey)

View File

@ -79,9 +79,9 @@ SECRET_KEY = env('DJANGO_SECRET_KEY')
INSTALLED_APPS = (
# 1st migrate
'hosting',
'membership',
'djangocms_admin_style',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.humanize',
@ -144,7 +144,6 @@ INSTALLED_APPS = (
# ungleich
'ungleich',
'ungleich_page',
'hosting',
'digitalglarus',
'nosystemd',
'datacenterlight',
@ -154,6 +153,7 @@ INSTALLED_APPS = (
'opennebula_api',
'django_celery_results',
'webhook',
'django.contrib.admin',
)
MIDDLEWARE_CLASSES = (
@ -196,6 +196,7 @@ TEMPLATES = [
os.path.join(PROJECT_DIR, 'cms_templates/'),
os.path.join(PROJECT_DIR, 'cms_templates/djangocms_blog/'),
os.path.join(PROJECT_DIR, 'templates/gdpr'),
os.path.join(PROJECT_DIR, 'templates'),
],
'APP_DIRS': True,
'OPTIONS': {

View File

@ -208,6 +208,25 @@ class UserHostingKey(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
name = models.CharField(max_length=100)
def __str__(self):
username = "None"
email = "None"
if self.user:
username = self.user.username
email = self.user.email
display_str = '''Username: %s,
Email: %s,
Key name: %s,
Created at: %s,
Public Key: %s''' % (
username,
email,
self.name,
self.created_at,
self.public_key
)
return display_str
@staticmethod
def generate_RSA(bits=2048):
'''

View File

@ -0,0 +1,18 @@
{% extends "admin/base_site.html" %}
{% block extrahead %}
<style>
table {
width: 90%;
border-spacing: 0;
border-collapse: collapse;
}
table thead th {
text-align: left;
}
th {
word-break: break-all;
}
</style>
{% endblock %}