Changeset - dd2774211489
[Not reviewed]
2 2 1
Ben Sturmfels (bsturmfels) - 2 months ago 2024-03-06 07:46:40
ben@sturm.com.au
Move Python code out of the "conservancy/static" directory

Having Python code in "conservancy/static" is a bit suprising to people familiar
with Django. The name "static" is usually reserved for assets like CSS, JS and
images.

I'm moving `conservancy/static/views.py` to `conservancy/views.py` and removing
`conservancy/static/__init__.py`.
4 files changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
conservancy/static/__init__.py
Show inline comments
 
deleted file
conservancy/supporter/urls.py
Show inline comments
 
from django.conf.urls import url
 
from django.views.generic import TemplateView
 

	
 
from . import views as supp_views
 
from ..static import views as static_views
 
from .. import views as static_views
 

	
 
INDEX_VIEW = supp_views.index
 
urlpatterns = [
 
    url(r'^$', INDEX_VIEW),
 
    url(r'^banners?/?$', TemplateView.as_view(template_name='supporter/banners.html')),
 
]
 
urlpatterns.extend(
 
    url(r'^{}(?:\.html|/|)$'.format(basename), INDEX_VIEW)
 
    for basename in ['index', '2015-supporter-appeal', '2016-supporter-appeal']
 
)
 
urlpatterns.append(url(r'', static_views.index))
conservancy/urls.py
Show inline comments
...
 
@@ -14,25 +14,25 @@
 
# General Public License for more details.
 
#
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 

	
 
from django.conf.urls import url
 
from django.urls import include, path
 
from django.contrib import admin
 

	
 
from . import feeds, frontpage, sponsors
 
from .fundgoal import views as fundgoal_views
 
from .static import views as static_views
 
from . import views as static_views
 

	
 
admin.autodiscover()
 

	
 
urlpatterns = [
 
    url(r'^$', frontpage.view),
 
    url(r'^sponsors$', frontpage.view),
 
    url(r'^sponsors/$', sponsors.view),
 
    url(r'^sponsors/index.html$', sponsors.view),
 
    url(r'^admin/', admin.site.urls),
 
    url(r'^feeds/blog/?$', feeds.BlogFeed()),
 
    url(r'^feeds/news/?$', feeds.PressReleaseFeed()),
 
    url(r'^feeds/omnibus/?$', feeds.OmnibusFeed()),
conservancy/views.py
Show inline comments
 
file renamed from conservancy/static/views.py to conservancy/views.py
 
import mimetypes
 
import os.path
 

	
 
from django.http import HttpResponse
 
from django.template.response import TemplateResponse
 

	
 
from ..local_context_processors import fundgoal_lookup
 
from .local_context_processors import fundgoal_lookup
 

	
 
STATIC_ROOT = os.path.abspath(os.path.dirname(__file__))
 
FILESYSTEM_ENCODING = 'utf-8'
 

	
 
def handler(request, errorcode):
 
    path = os.path.join('error', str(errorcode), 'index.html')
 
    fullpath = os.path.join(STATIC_ROOT, path)
 
    if not os.path.exists(fullpath):
 
        return HttpResponse("Internal error: " + path, status=int(errorcode))
 
    else:
 
        return TemplateResponse(request, path, status=int(errorcode))
 

	
0 comments (0 inline, 0 general)