Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
delete unused code from project app
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzylogic2000 committed Mar 5, 2019
1 parent c185b80 commit 653251e
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 331 deletions.
37 changes: 0 additions & 37 deletions liqd_product/apps/dashboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,13 @@
from adhocracy4.dashboard import components
from adhocracy4.dashboard import ProjectDashboard
from liqd_product.apps.projects import get_project_type


default_app_config = 'liqd_product.apps.dashboard.apps.Config'


class TypedProjectDashboard(ProjectDashboard):
def __init__(self, project):
self.project_type = get_project_type(project)
if self.project_type == 'bplan':
project = project.externalproject.bplan
elif self.project_type == 'external':
project = project.externalproject
elif self.project_type == 'container':
project = project.projectcontainer
super().__init__(project)

def get_project_components(self):
if self.project_type == 'bplan':
return [components.projects.get('bplan'),
components.projects.get('plans'),
components.projects.get('adminlog')]
elif self.project_type == 'external':
return [components.projects.get('external'),
components.projects.get('topics'),
components.projects.get('point'),
components.projects.get('plans'),
components.projects.get('adminlog')]
elif self.project_type == 'container':
return [components.projects.get('container-basic'),
components.projects.get('container-information'),
components.projects.get('topics'),
components.projects.get('point'),
components.projects.get('plans'),
components.projects.get('container-projects')]

return [component for component in components.get_project_components()
if component.is_effective(self.project)]

def get_module_components(self):
if self.project_type == 'bplan':
return []
elif self.project_type == 'external':
return []
elif self.project_type == 'container':
return []

return components.get_module_components()
16 changes: 6 additions & 10 deletions liqd_product/apps/embed/templates/liqd_product_embed/embed.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@

<body data-url="{{ object.get_absolute_url }}">
<header class="embed-header">
{% if not object|is_external %}
{% if request.user.is_anonymous %}
<a href="{% url 'account_login' %}" class="btn btn--light">{% trans 'Login' %}</a>
{% else %}
{% trans 'You are logged in as ' %} {{ request.user.username }}
<a href="{% url 'account_logout' %}" class="js-embed-logout btn btn--light" target="_blank">{% trans 'Logout' %}</a>
{% endif %}
{% if request.user.is_anonymous %}
<a href="{% url 'account_login' %}" class="btn btn--light">{% trans 'Login' %}</a>
{% else %}
{% trans 'You are logged in as ' %} {{ request.user.username }}
<a href="{% url 'account_logout' %}" class="js-embed-logout btn btn--light" target="_blank">{% trans 'Logout' %}</a>
{% endif %}
<div id="embed-status" class="embed-status"></div>
</header>
Expand All @@ -35,9 +33,7 @@
<a href="/" target="_blank">
Beteiligung.in
</a>
{% if not object|is_external %}
<a href="{{ object.get_absolute_url }}" data-embed-target="external">{% trans 'Go to platform' %}</a>
{% endif %}
<a href="{{ object.get_absolute_url }}" data-embed-target="external">{% trans 'Go to platform' %}</a>
</footer>
<div id="embed-confirm" class="modal" tabindex="-1" role="dialog" aria-label="{% trans 'Confirm login' %}" aria-hidden="true">
<div class="modal-dialog">
Expand Down
16 changes: 0 additions & 16 deletions liqd_product/apps/projects/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
from functools import lru_cache


default_app_config = 'liqd_product.apps.projects.apps.Config'


@lru_cache(maxsize=32)
def get_project_type(project):
if (hasattr(project, 'externalproject') and
hasattr(project.externalproject, 'bplan')):
return 'bplan'
elif hasattr(project, 'externalproject'):
return 'external'
elif hasattr(project, 'projectcontainer'):
return 'container'
else:
return 'default'
5 changes: 0 additions & 5 deletions liqd_product/apps/projects/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ class ProjectAdmin(admin.ModelAdmin):
}),
)

def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'administrative_district':
kwargs['empty_label'] = _('City wide')
return super().formfield_for_foreignkey(db_field, request, **kwargs)


# Overwrite adhocracy4.projects.admin
admin.site.unregister(models.Project)
Expand Down

This file was deleted.

0 comments on commit 653251e

Please sign in to comment.