websites complete fusion

This commit is contained in:
jorgepastorr 2023-08-08 16:20:46 +02:00
parent 3804e0d5ea
commit 1391061233
3 changed files with 75 additions and 27 deletions

View file

@ -60,7 +60,7 @@ class ContentInline(AccountAdminMixin, admin.TabularInline):
class WebsiteAdmin(SelectAccountAdminMixin, ExtendedModelAdmin): class WebsiteAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
list_display = ( list_display = (
'name', 'display_domains', 'display_webapps', 'account_link', 'display_active' 'name', 'display_domains', 'display_webapps', 'account_link', 'target_server', 'display_active'
) )
list_filter = ( list_filter = (
'protocol', IsActiveListFilter, HasWebAppsListFilter, HasDomainsFilter 'protocol', IsActiveListFilter, HasWebAppsListFilter, HasDomainsFilter

View file

@ -4,6 +4,7 @@ import textwrap
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from orchestra.contrib.orchestration import ServiceController from orchestra.contrib.orchestration import ServiceController
from orchestra.settings import NEW_SERVERS
from .. import settings from .. import settings
@ -29,7 +30,8 @@ class WebalizerController(ServiceController):
cat << 'EOF' > %(webalizer_conf_path)s cat << 'EOF' > %(webalizer_conf_path)s
%(webalizer_conf)s %(webalizer_conf)s
EOF EOF
chown %(user)s:www-data %(webalizer_path)s # chown %(user)s:www-data %(webalizer_path)s
chown www-data:www-data %(webalizer_path)s
chmod g+xr %(webalizer_path)s chmod g+xr %(webalizer_path)s
""") % context """) % context
) )
@ -54,7 +56,21 @@ class WebalizerController(ServiceController):
'webalizer_conf_path': os.path.join(settings.WEBSITES_WEBALIZER_PATH, conf_file), 'webalizer_conf_path': os.path.join(settings.WEBSITES_WEBALIZER_PATH, conf_file),
'user': content.webapp.account.username, 'user': content.webapp.account.username,
'banner': self.get_banner(), 'banner': self.get_banner(),
'target_server': content.website.target_server,
} }
if context.get('target_server').name in NEW_SERVERS:
context['webalizer_conf'] = textwrap.dedent("""\
# %(banner)s
LogFile %(site_logs)s
LogType clf
OutputDir %(webalizer_path)s
HistoryName awffull.hist
Incremental yes
IncrementalName awffull.current
ReportTitle Stats of
HostName %(site_name)s
""") % context
else:
context['webalizer_conf'] = textwrap.dedent("""\ context['webalizer_conf'] = textwrap.dedent("""\
# %(banner)s # %(banner)s
LogFile %(site_logs)s LogFile %(site_logs)s
@ -65,6 +81,9 @@ class WebalizerController(ServiceController):
IncrementalName webalizer.current IncrementalName webalizer.current
ReportTitle Stats of ReportTitle Stats of
HostName %(site_name)s HostName %(site_name)s
""") % context
context['webalizer_conf'] = context['webalizer_conf'] + textwrap.dedent("""\
PageType htm* PageType htm*
PageType php* PageType php*
@ -85,19 +104,27 @@ class WebalizerController(ServiceController):
IncludeURL * IncludeURL *
SearchEngine yahoo.com p= SearchEngine google. q=
SearchEngine altavista.com q= SearchEngine yahoo. p=
SearchEngine google.com q= SearchEngine msn. q=
SearchEngine eureka.com q= SearchEngine search.aol query=
SearchEngine lycos.com query= SearchEngine altavista. q=
SearchEngine hotbot.com MT= SearchEngine lycos. query=
SearchEngine msn.com MT= SearchEngine hotbot. query=
SearchEngine infoseek.com qt= SearchEngine alltheweb. query=
SearchEngine infoseek. qt=
SearchEngine webcrawler searchText= SearchEngine webcrawler searchText=
SearchEngine excite search= SearchEngine excite search=
SearchEngine netscape.com search= SearchEngine netscape. query=
SearchEngine ask.com q=
SearchEngine webwombat. ix=
SearchEngine earthlink. q=
SearchEngine search.comcast. q=
SearchEngine search.mywebsearch. searchfor=
SearchEngine reference.com q=
SearchEngine mamma.com query= SearchEngine mamma.com query=
SearchEngine alltheweb.com query= # Last attempt catch all
SearchEngine search. q=
DumpSites yes""") % context DumpSites yes""") % context
return context return context

View file

@ -3,6 +3,8 @@ from collections import defaultdict
from django import forms from django import forms
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from orchestra.contrib.webapps.models import WebApp
from .utils import normurlpath from .utils import normurlpath
from .validators import validate_domain_protocol, validate_server_name from .validators import validate_domain_protocol, validate_server_name
@ -27,6 +29,25 @@ class WebsiteAdminForm(forms.ModelForm):
self.add_error('domains', err) self.add_error('domains', err)
return self.cleaned_data return self.cleaned_data
def clean_target_server(self):
# valida que el webapp pertenezca al server indicado
try:
server = self.cleaned_data['target_server']
except:
server = self.instance.target_server
diferentServer = False
for i in range(int(self.data['content_set-TOTAL_FORMS']) + 1):
if f"content_set-{i}-webapp" in self.data.keys() and f"content_set-{i}-DELETE" not in self.data.keys():
if self.data[f"content_set-{i}-webapp"]:
idWebapp = self.data[f"content_set-{i}-webapp"]
webapp = WebApp.objects.get(id=idWebapp)
if webapp.target_server.id != server.id :
diferentServer = True
if diferentServer:
self.add_error("target_server", f"Some Webapp does not belong to the {server.name} server")
return server
class WebsiteDirectiveInlineFormSet(forms.models.BaseInlineFormSet): class WebsiteDirectiveInlineFormSet(forms.models.BaseInlineFormSet):
def clean(self): def clean(self):