From 4230fd636eb1974fadff1540c92547b7c18543a5 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 25 Aug 2020 13:37:59 -0400 Subject: [PATCH] Updating example plugin with pre_remove, static js, template file, and a model. --- examplePlugin/enable_migrations | 0 examplePlugin/models.py | 8 ++- examplePlugin/post_install | 6 +-- examplePlugin/pre_install | 6 +-- examplePlugin/pre_remove | 4 ++ .../static/examplePlugin/examplePlugin.js | 3 ++ .../examplePlugin/examplePlugin.html | 52 +++++++++++++++++++ examplePlugin/views.py | 2 +- 8 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 examplePlugin/enable_migrations create mode 100644 examplePlugin/pre_remove create mode 100644 examplePlugin/static/examplePlugin/examplePlugin.js create mode 100644 examplePlugin/templates/examplePlugin/examplePlugin.html diff --git a/examplePlugin/enable_migrations b/examplePlugin/enable_migrations new file mode 100644 index 000000000..e69de29bb diff --git a/examplePlugin/models.py b/examplePlugin/models.py index 71a836239..c2f360a3c 100755 --- a/examplePlugin/models.py +++ b/examplePlugin/models.py @@ -1,3 +1,9 @@ from django.db import models -# Create your models here. + +class ExamplePlugin(models.Model): + name = models.CharField(unique=True, max_length=255) + + class Meta: + # db_table = "ExamplePlugin" + pass diff --git a/examplePlugin/post_install b/examplePlugin/post_install index c4c6c1c9f..01ec2cce3 100644 --- a/examplePlugin/post_install +++ b/examplePlugin/post_install @@ -1,4 +1,4 @@ #!/usr/local/CyberCP/bin/python -RESET='\033[0;0m' -BLUE="\033[0;34m" -print(BLUE + "Running Post-Install Script..." + RESET) \ No newline at end of file +RESET = '\033[0;0m' +BLUE = "\033[0;34m" +print(BLUE + "Running Post-Install Script..." + RESET) diff --git a/examplePlugin/pre_install b/examplePlugin/pre_install index 6c4fcea9f..c14bef694 100644 --- a/examplePlugin/pre_install +++ b/examplePlugin/pre_install @@ -1,4 +1,4 @@ #!/usr/local/CyberCP/bin/python -RESET='\033[0;0m' -GREEN='\033[0;32m' -print(GREEN + "Running Pre-Install Script..." + RESET) \ No newline at end of file +RESET = '\033[0;0m' +GREEN = '\033[0;32m' +print(GREEN + "Running Pre-Install Script..." + RESET) diff --git a/examplePlugin/pre_remove b/examplePlugin/pre_remove new file mode 100644 index 000000000..eb54102ec --- /dev/null +++ b/examplePlugin/pre_remove @@ -0,0 +1,4 @@ +#!/usr/local/CyberCP/bin/python +RESET = '\033[0;0m' +GREEN = '\033[0;32m' +print(GREEN + "Running Pre-Remove Script..." + RESET) diff --git a/examplePlugin/static/examplePlugin/examplePlugin.js b/examplePlugin/static/examplePlugin/examplePlugin.js new file mode 100644 index 000000000..c10ce8398 --- /dev/null +++ b/examplePlugin/static/examplePlugin/examplePlugin.js @@ -0,0 +1,3 @@ +$(document).ready(function () { + console.log("using JS in static file...!"); +}); \ No newline at end of file diff --git a/examplePlugin/templates/examplePlugin/examplePlugin.html b/examplePlugin/templates/examplePlugin/examplePlugin.html new file mode 100644 index 000000000..428ac6c05 --- /dev/null +++ b/examplePlugin/templates/examplePlugin/examplePlugin.html @@ -0,0 +1,52 @@ +{% extends "baseTemplate/index.html" %} +{% load i18n %} +{% block styles %} + +{% endblock %} +{% block title %}Example plugin - CyberPanel{% endblock %} +{% block content %} + {% load static %} + {% get_current_language as LANGUAGE_CODE %} + +
+ +
+

{% trans "Example Plugin Page" %}

+

{% trans "Example Plugin Info" %}

+
+ +
+
+

{% trans "examplePlugin" %}

+
+
+
+

[[ pluginBody ]]

+
+
+
+ +
+{% endblock %} + +{% block footer_scripts %} + + {# #} + + +{% endblock %} diff --git a/examplePlugin/views.py b/examplePlugin/views.py index 3eba085fb..2845a8f61 100755 --- a/examplePlugin/views.py +++ b/examplePlugin/views.py @@ -4,4 +4,4 @@ from django.shortcuts import render, HttpResponse # Create your views here. def examplePlugin(request): - return HttpResponse('This is homepage of an example plugin.') + return render(request, 'examplePlugin/examplePlugin.html')