Modules
This commit is contained in:
		
							parent
							
								
									0a4fcc0869
								
							
						
					
					
						commit
						35669526cf
					
				
							
								
								
									
										0
									
								
								modules/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								modules/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										34
									
								
								modules/api/portal/add.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								modules/api/portal/add.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,34 @@
 | 
			
		||||
import mysql.connector  as mariadb
 | 
			
		||||
import config.database  as database
 | 
			
		||||
import config.globalvar as globalvar
 | 
			
		||||
 | 
			
		||||
class main:
 | 
			
		||||
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    def result(self, params):
 | 
			
		||||
        response = {
 | 
			
		||||
            "message_action" : "success" ,
 | 
			
		||||
            "message_desc"   : "New portal created" ,
 | 
			
		||||
            "message_data"   : {
 | 
			
		||||
                "title"     : params['title'     ],
 | 
			
		||||
                "website"   : params['website'   ],
 | 
			
		||||
                "logo"      : params['logo'      ],
 | 
			
		||||
                "directory" : params['directory' ],
 | 
			
		||||
            },
 | 
			
		||||
        }
 | 
			
		||||
        if params['logo']:
 | 
			
		||||
            query = f"INSERT INTO portal VALUES (DEFAULT, '{params['title']}', NULL, '{params['website']}', '{params['logo']}', '{params['directory']}')"
 | 
			
		||||
        else:
 | 
			
		||||
            query = f"INSERT INTO portal VALUES (DEFAULT, '{params['title']}', NULL, '{params['website']}', NULL, '{params['directory']}')"
 | 
			
		||||
        try:
 | 
			
		||||
            con     = mariadb.connect(**database.main_db)
 | 
			
		||||
            cursor  = con.cursor()
 | 
			
		||||
            cursor.execute(query)
 | 
			
		||||
            con.close()
 | 
			
		||||
        except Exception as e:
 | 
			
		||||
            print(f"Error: {e}")
 | 
			
		||||
            response["message_action" ] = "failed",
 | 
			
		||||
            response["message_desc"   ] = f"error: {e}"
 | 
			
		||||
        return response
 | 
			
		||||
							
								
								
									
										0
									
								
								modules/user/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								modules/user/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										35
									
								
								modules/user/home.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								modules/user/home.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
			
		||||
from   mako.template    import Template
 | 
			
		||||
import mysql.connector  as mariadb
 | 
			
		||||
import config.database  as database
 | 
			
		||||
import config.globalvar as globalvar
 | 
			
		||||
 | 
			
		||||
class main:
 | 
			
		||||
 | 
			
		||||
	def __init__(self):
 | 
			
		||||
 		pass
 | 
			
		||||
 | 
			
		||||
	def html(self, params):
 | 
			
		||||
 | 
			
		||||
		interface_template = params["params_page"]['template'  ]
 | 
			
		||||
		topnav             = params["params_page"]['topnav'    ]
 | 
			
		||||
		footer             = params["params_page"]['footer'    ]
 | 
			
		||||
		container          = params["params_page"]['container' ]
 | 
			
		||||
 | 
			
		||||
		con                = mariadb.connect(**database.main_db)
 | 
			
		||||
		cursor             = con.cursor()
 | 
			
		||||
		cursor.execute("SELECT id, title, logo FROM portal")
 | 
			
		||||
		listing_portal     = cursor.fetchall()
 | 
			
		||||
		con.close()
 | 
			
		||||
 | 
			
		||||
		return Template(interface_template).render(
 | 
			
		||||
			GV_title    = globalvar.GV_title,
 | 
			
		||||
			GV_base_url = globalvar.GV_base_url,
 | 
			
		||||
			topnav      = Template(topnav).render(
 | 
			
		||||
				GV_title = globalvar.GV_title,
 | 
			
		||||
			),
 | 
			
		||||
			footer      = Template(footer).render(),
 | 
			
		||||
            container   = Template(container).render(
 | 
			
		||||
				GV_base_url    = globalvar.GV_base_url,
 | 
			
		||||
				listing_portal = listing_portal
 | 
			
		||||
			)
 | 
			
		||||
        )
 | 
			
		||||
							
								
								
									
										69
									
								
								modules/user/portal.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								modules/user/portal.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,69 @@
 | 
			
		||||
import cherrypy
 | 
			
		||||
 | 
			
		||||
from   mako.template    import Template
 | 
			
		||||
import mysql.connector  as mariadb
 | 
			
		||||
 | 
			
		||||
import config.database  as database
 | 
			
		||||
import config.globalvar as globalvar
 | 
			
		||||
 | 
			
		||||
import core.melon       as melon
 | 
			
		||||
 | 
			
		||||
class main:
 | 
			
		||||
 | 
			
		||||
	def __init__(self):
 | 
			
		||||
 		pass
 | 
			
		||||
 | 
			
		||||
	def html(self, params):
 | 
			
		||||
 | 
			
		||||
		interface_template = params["params_page"]['template'  ]
 | 
			
		||||
		topnav             = params["params_page"]['topnav'    ]
 | 
			
		||||
		footer             = params["params_page"]['footer'    ]
 | 
			
		||||
		container          = params["params_page"]['container' ]
 | 
			
		||||
 | 
			
		||||
		portal_id          = params["id"]
 | 
			
		||||
 | 
			
		||||
		con                = mariadb.connect(**database.main_db)
 | 
			
		||||
		cursor             = con.cursor()
 | 
			
		||||
		cursor.execute(f"SELECT * FROM portal WHERE id = {portal_id} ")
 | 
			
		||||
		listing_portal     = cursor.fetchone()
 | 
			
		||||
		con.close()
 | 
			
		||||
 | 
			
		||||
		portal_info	= {
 | 
			
		||||
			'title'       : listing_portal[1],
 | 
			
		||||
			'description' : listing_portal[2],
 | 
			
		||||
			'website'     : listing_portal[3],
 | 
			
		||||
			'logo'        : listing_portal[4],
 | 
			
		||||
			'directory'   : listing_portal[5],
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		storage_available = melon.CheckDir(portal_info['directory'])
 | 
			
		||||
		checking_status   = None
 | 
			
		||||
		new_file_info     = None
 | 
			
		||||
 | 
			
		||||
		if storage_available:
 | 
			
		||||
			checking_status	= melon.CountCompare(portal_info['directory'], database.main_db, 'video', 'id_portal', portal_id)
 | 
			
		||||
 | 
			
		||||
			if checking_status == 'new':
 | 
			
		||||
				new_file_info = melon.NewFileDetector(portal_info['directory'], database.main_db, 'video', 'static/media/thumbs/')
 | 
			
		||||
			elif checking_status == 'miss':
 | 
			
		||||
				pass
 | 
			
		||||
			elif checking_status == 'ok':
 | 
			
		||||
				pass
 | 
			
		||||
			else:
 | 
			
		||||
				pass
 | 
			
		||||
 | 
			
		||||
		return Template(interface_template).render(
 | 
			
		||||
			GV_title    = globalvar.GV_title,
 | 
			
		||||
			GV_base_url = globalvar.GV_base_url,
 | 
			
		||||
			topnav      = Template(topnav).render(
 | 
			
		||||
				GV_title = globalvar.GV_title,
 | 
			
		||||
			),
 | 
			
		||||
			footer      = Template(footer).render(),
 | 
			
		||||
            container   = Template(container).render(
 | 
			
		||||
				GV_base_url       = globalvar.GV_base_url,
 | 
			
		||||
				portal_info       = portal_info,
 | 
			
		||||
				storage_available = storage_available,
 | 
			
		||||
				checking_status   = checking_status,
 | 
			
		||||
				new_file_info     = new_file_info,
 | 
			
		||||
			)
 | 
			
		||||
        )
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user