Browse Source

drop default view

Guénaël Muller 7 years ago
parent
commit
b1cbccf8ad

BIN
tracim/static/pyramid-16x16.png View File


BIN
tracim/static/pyramid.png View File


+ 0 - 154
tracim/static/theme.css View File

@@ -1,154 +0,0 @@
1
-@import url(//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700);
2
-body {
3
-  font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
4
-  font-weight: 300;
5
-  color: #ffffff;
6
-  background: #bc2131;
7
-}
8
-h1,
9
-h2,
10
-h3,
11
-h4,
12
-h5,
13
-h6 {
14
-  font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
15
-  font-weight: 300;
16
-}
17
-p {
18
-  font-weight: 300;
19
-}
20
-.font-normal {
21
-  font-weight: 400;
22
-}
23
-.font-semi-bold {
24
-  font-weight: 600;
25
-}
26
-.font-bold {
27
-  font-weight: 700;
28
-}
29
-.starter-template {
30
-  margin-top: 250px;
31
-}
32
-.starter-template .content {
33
-  margin-left: 10px;
34
-}
35
-.starter-template .content h1 {
36
-  margin-top: 10px;
37
-  font-size: 60px;
38
-}
39
-.starter-template .content h1 .smaller {
40
-  font-size: 40px;
41
-  color: #f2b7bd;
42
-}
43
-.starter-template .content .lead {
44
-  font-size: 25px;
45
-  color: #f2b7bd;
46
-}
47
-.starter-template .content .lead .font-normal {
48
-  color: #ffffff;
49
-}
50
-.starter-template .links {
51
-  float: right;
52
-  right: 0;
53
-  margin-top: 125px;
54
-}
55
-.starter-template .links ul {
56
-  display: block;
57
-  padding: 0;
58
-  margin: 0;
59
-}
60
-.starter-template .links ul li {
61
-  list-style: none;
62
-  display: inline;
63
-  margin: 0 10px;
64
-}
65
-.starter-template .links ul li:first-child {
66
-  margin-left: 0;
67
-}
68
-.starter-template .links ul li:last-child {
69
-  margin-right: 0;
70
-}
71
-.starter-template .links ul li.current-version {
72
-  color: #f2b7bd;
73
-  font-weight: 400;
74
-}
75
-.starter-template .links ul li a, a {
76
-  color: #f2b7bd;
77
-  text-decoration: underline;
78
-}
79
-.starter-template .links ul li a:hover, a:hover {
80
-  color: #ffffff;
81
-  text-decoration: underline;
82
-}
83
-.starter-template .links ul li .icon-muted {
84
-  color: #eb8b95;
85
-  margin-right: 5px;
86
-}
87
-.starter-template .links ul li:hover .icon-muted {
88
-  color: #ffffff;
89
-}
90
-.starter-template .copyright {
91
-  margin-top: 10px;
92
-  font-size: 0.9em;
93
-  color: #f2b7bd;
94
-  text-transform: lowercase;
95
-  float: right;
96
-  right: 0;
97
-}
98
-@media (max-width: 1199px) {
99
-  .starter-template .content h1 {
100
-    font-size: 45px;
101
-  }
102
-  .starter-template .content h1 .smaller {
103
-    font-size: 30px;
104
-  }
105
-  .starter-template .content .lead {
106
-    font-size: 20px;
107
-  }
108
-}
109
-@media (max-width: 991px) {
110
-  .starter-template {
111
-    margin-top: 0;
112
-  }
113
-  .starter-template .logo {
114
-    margin: 40px auto;
115
-  }
116
-  .starter-template .content {
117
-    margin-left: 0;
118
-    text-align: center;
119
-  }
120
-  .starter-template .content h1 {
121
-    margin-bottom: 20px;
122
-  }
123
-  .starter-template .links {
124
-    float: none;
125
-    text-align: center;
126
-    margin-top: 60px;
127
-  }
128
-  .starter-template .copyright {
129
-    float: none;
130
-    text-align: center;
131
-  }
132
-}
133
-@media (max-width: 767px) {
134
-  .starter-template .content h1 .smaller {
135
-    font-size: 25px;
136
-    display: block;
137
-  }
138
-  .starter-template .content .lead {
139
-    font-size: 16px;
140
-  }
141
-  .starter-template .links {
142
-    margin-top: 40px;
143
-  }
144
-  .starter-template .links ul li {
145
-    display: block;
146
-    margin: 0;
147
-  }
148
-  .starter-template .links ul li .icon-muted {
149
-    display: none;
150
-  }
151
-  .starter-template .copyright {
152
-    margin-top: 20px;
153
-  }
154
-}

+ 0 - 9
tracim/templates/404.jinja2 View File

@@ -1,9 +0,0 @@
1
-<!-- TODO - G.M - 28-03-2018 - [Cleanup] Replace this example template -->
2
-{% extends "layout.jinja2" %}
3
-
4
-{% block content %}
5
-<div class="content">
6
-  <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Alchemy scaffold</span></h1>
7
-  <p class="lead"><span class="font-semi-bold">404</span> Page Not Found</p>
8
-</div>
9
-{% endblock content %}

+ 0 - 65
tracim/templates/layout.jinja2 View File

@@ -1,65 +0,0 @@
1
-<!-- TODO - G.M - 28-03-2018 - [Cleanup] Remove this example template -->
2
-<!DOCTYPE html>
3
-<html lang="{{request.locale_name}}">
4
-  <head>
5
-    <meta charset="utf-8">
6
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
7
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
-    <meta name="description" content="pyramid web application">
9
-    <meta name="author" content="Pylons Project">
10
-    <link rel="shortcut icon" href="{{request.static_url('tracim:static/pyramid-16x16.png')}}">
11
-
12
-    <title>Cookiecutter Alchemy project for the Pyramid Web Framework</title>
13
-
14
-    <!-- Bootstrap core CSS -->
15
-    <link href="//oss.maxcdn.com/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
16
-
17
-    <!-- Custom styles for this scaffold -->
18
-    <link href="{{request.static_url('tracim:static/theme.css')}}" rel="stylesheet">
19
-
20
-    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
21
-    <!--[if lt IE 9]>
22
-      <script src="//oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js" integrity="sha384-0s5Pv64cNZJieYFkXYOTId2HMA2Lfb6q2nAcx2n0RTLUnCAoTTsS0nKEO27XyKcY" crossorigin="anonymous"></script>
23
-      <script src="//oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js" integrity="sha384-f1r2UzjsxZ9T4V1f2zBO/evUqSEOpeaUUZcMTz1Up63bl4ruYnFYeM+BxI4NhyI0" crossorigin="anonymous"></script>
24
-    <![endif]-->
25
-  </head>
26
-
27
-  <body>
28
-
29
-    <div class="starter-template">
30
-      <div class="container">
31
-        <div class="row">
32
-          <div class="col-md-2">
33
-            <img class="logo img-responsive" src="{{request.static_url('tracim:static/pyramid.png') }}" alt="pyramid web framework">
34
-          </div>
35
-          <div class="col-md-10">
36
-            {% block content %}
37
-                <p>No content</p>
38
-            {% endblock content %}
39
-          </div>
40
-        </div>
41
-        <div class="row">
42
-          <div class="links">
43
-            <ul>
44
-              <li><i class="glyphicon glyphicon-cog icon-muted"></i><a href="https://github.com/Pylons/pyramid">Github Project</a></li>
45
-              <li><i class="glyphicon glyphicon-globe icon-muted"></i><a href="https://webchat.freenode.net/?channels=pyramid">IRC Channel</a></li>
46
-              <li><i class="glyphicon glyphicon-home icon-muted"></i><a href="https://pylonsproject.org">Pylons Project</a></li>
47
-            </ul>
48
-          </div>
49
-        </div>
50
-        <div class="row">
51
-          <div class="copyright">
52
-            Copyright &copy; Pylons Project
53
-          </div>
54
-        </div>
55
-      </div>
56
-    </div>
57
-
58
-
59
-    <!-- Bootstrap core JavaScript
60
-    ================================================== -->
61
-    <!-- Placed at the end of the document so the pages load faster -->
62
-    <script src="//oss.maxcdn.com/libs/jquery/1.10.2/jquery.min.js" integrity="sha384-aBL3Lzi6c9LNDGvpHkZrrm3ZVsIwohDD7CDozL0pk8FwCrfmV7H9w8j3L7ikEv6h" crossorigin="anonymous"></script>
63
-    <script src="//oss.maxcdn.com/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js" integrity="sha384-s1ITto93iSMDxlp/79qhWHi+LsIi9Gx6yL+cOKDuymvihkfol83TYbLbOw+W/wv4" crossorigin="anonymous"></script>
64
-  </body>
65
-</html>

+ 0 - 9
tracim/templates/mytemplate.jinja2 View File

@@ -1,9 +0,0 @@
1
-<!-- TODO - G.M - 28-03-2018 - [Cleanup] Remove this example template -->
2
-{% extends "layout.jinja2" %}
3
-
4
-{% block content %}
5
-<div class="content">
6
-  <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Alchemy project</span></h1>
7
-  <p class="lead">Welcome to <span class="font-normal">{{ project }}</span>, a&nbsp;Pyramid application generated&nbsp;by<br><span class="font-normal">Cookiecutter</span>.</p>
8
-</div>
9
-{% endblock content %}

+ 2 - 108
tracim/views/default/default_controller.py View File

@@ -1,125 +1,19 @@
1 1
 # coding=utf-8
2
-from pyramid.request import Request
3
-
4 2
 from tracim import TracimRequest
5
-from tracim.models import Group
6
-from tracim.models.data import UserRoleInWorkspace
7 3
 from tracim.views.controllers import Controller
8 4
 from pyramid.config import Configurator
9
-from pyramid.response import Response
10 5
 from pyramid.exceptions import NotFound
11
-from pyramid.httpexceptions import HTTPUnauthorized
12
-from pyramid.httpexceptions import HTTPForbidden
13
-from pyramid.security import forget, authenticated_userid
14
-
15
-from tracim.lib.utils.authorization import require_workspace_role, \
16
-    require_profile
17 6
 
18 7
 
19 8
 class DefaultController(Controller):
20 9
 
21
-    def notfound_view(self, request):
10
+    def notfound_view(self, request:TracimRequest):
22 11
         request.response.status = 404
23 12
         return {}
24 13
 
25
-    def forbidden_view(self, request):
26
-        if request.authenticated_userid is None:
27
-            response = HTTPUnauthorized()
28
-            response.headers.update(forget(request))
29
-
30
-        # user is logged in but doesn't have permissions, reject wholesale
31
-        else:
32
-            response = HTTPForbidden()
33
-        return response
34
-
35
-    def home(self, request: TracimRequest):
36
-        app_config = request.registry.settings['CFG']
37
-        project = app_config.WEBSITE_TITLE
38
-        return {'project': project}
39
-
40
-    @require_profile(Group.TIM_USER)
41
-    def user(self, request: TracimRequest):
42
-        return self.home(request)
43
-
44
-    # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method
45
-    @require_workspace_role(UserRoleInWorkspace.READER)
46
-    def test_reader(self, request: TracimRequest):
47
-        return self.home(request)
48
-
49
-    # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method
50
-    @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
51
-    def test_contributor(self, request):
52
-        return self.home(request)
53
-
54
-    # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method
55
-    @require_workspace_role(UserRoleInWorkspace.WORKSPACE_MANAGER)
56
-    def test_workspace_manager(self, request):
57
-        return self.home(request)
58
-
59
-    # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method
60
-    @require_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
61
-    def test_content_manager(self, request):
62
-        return self.home(request)
63
-
64 14
     def bind(self, configurator: Configurator):
65
-        # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop static files
66
-        configurator.add_static_view('static', 'static', cache_max_age=3600)
67
-        # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Do not rely
68
-        # on static file for 404 view
69 15
         configurator.add_view(
70 16
             self.notfound_view,
71
-            renderer='tracim:templates/404.jinja2',
17
+            renderer='json',
72 18
             context=NotFound,
73 19
         )
74
-
75
-        # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method
76
-        configurator.add_route('home', '/')
77
-        configurator.add_view(
78
-            self.home,
79
-            route_name='home',
80
-            renderer='tracim:templates/mytemplate.jinja2',
81
-        )
82
-        # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method
83
-        configurator.add_route('user', '/test_user')
84
-        configurator.add_view(
85
-            self.user,
86
-            route_name='user',
87
-            renderer='tracim:templates/mytemplate.jinja2',
88
-        )
89
-
90
-        # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method
91
-        configurator.add_route('test_contributor', '/test_contributor')
92
-        configurator.add_view(
93
-            self.test_contributor,
94
-            route_name='test_contributor',
95
-            renderer='tracim:templates/mytemplate.jinja2',
96
-        )
97
-        # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method
98
-        configurator.add_route('test_reader', '/test_reader')
99
-        configurator.add_view(
100
-            self.test_contributor,
101
-            route_name='test_reader',
102
-            renderer='tracim:templates/mytemplate.jinja2',
103
-        )
104
-        # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method
105
-        configurator.add_route(
106
-            'test_workspace_manager',
107
-            '/test_workspace_manager'
108
-        )
109
-        configurator.add_view(
110
-            self.test_workspace_manager,
111
-            route_name='test_workspace_manager',
112
-            renderer='tracim:templates/mytemplate.jinja2',
113
-        )
114
-
115
-        # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method
116
-        configurator.add_route(
117
-            'test_content_manager',
118
-            '/test_content_manager'
119
-        )
120
-        configurator.add_view(
121
-            self.test_content_manager,
122
-            route_name='test_content_manager',
123
-            renderer='tracim:templates/mytemplate.jinja2',
124
-        )
125
-        configurator.add_forbidden_view(self.forbidden_view)