瀏覽代碼

Made improvement to make application work

Joost Sijm 3 年之前
父節點
當前提交
b7c4efd6e3

+ 1 - 0
.gitignore

@@ -6,5 +6,6 @@
 node_modules/
 __pycache__/
 .venv/
+log/
 .env
 app/static/js/main.js

+ 1 - 1
app/modules/auth/app.py

@@ -92,4 +92,4 @@ def register():
 def logout():
     """Logout function for users"""
     logout_user()
-    return redirect('')
+    return redirect('/')

+ 7 - 12
app/modules/backend/modules/file/app.py

@@ -73,24 +73,19 @@ def edit(file_id):
         file = None
         if 'file' in request.files:
             file = request.files['file']
-            if file.filename == '':
-                flash('No file selected', 'warning')
-                return redirect(request.url)
-            if file and allowed_file(file.filename):
+            if file and file.filename != '' and allowed_file(file.filename):
                 filename = secure_filename(file.filename)
                 file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
-
-        filename = db_file.path
-        if file is not None:
-            db_file.path = file.filename
+                db_file.path = filename
         if request.form['title']:
-            title = request.form['title'] 
+            title = request.form['title']
             url = quote(title.strip().lower().replace(" ", "_"))
+            old_path = db_file.path
             db_file.path = secure_filename('%s.%s' % (url, db_file.path.rsplit('.', 1)[1]))
-            os.rename(os.path.join(app.config['UPLOAD_FOLDER'], filename), os.path.join(app.config['UPLOAD_FOLDER'], db_file.path))
+            os.replace(os.path.join(app.config['UPLOAD_FOLDER'], old_path), os.path.join(app.config['UPLOAD_FOLDER'], db_file.path))
 
-        db_file.title = title 
-        db_file.user_id = current_user.id
+            db_file.title = title
+            db_file.user_id = current_user.id
 
         db.session.add(db_file)
         db.session.commit()

+ 1 - 1
app/modules/backend/modules/user/app.py

@@ -60,7 +60,7 @@ def remove(user_id):
     db.session.delete(user)
     db.session.commit()
 
-    flash('User "%s" successfully remove' % user.name, 'success')
+    flash('User "%s" successfully removed.' % user.name, 'success')
     return redirect(url_for('backend.index'))
 
 

+ 2 - 2
app/modules/backend/modules/vote/templates/backend_vote/create.j2

@@ -34,8 +34,8 @@
         <label class="text-normal text-dark">Priority</label>
         <select class="form-control" name="priority_id">
             <option></option>
-            {% for prioritiy in priorities %}
-            <option value="{{ page.id }}">{{ priority.name }}</option>
+            {% for priority in priorities %}
+            <option value="{{ priority.id }}">{{ priority.name }}</option>
             {% endfor %}
         </select>
     </div>

+ 1 - 0
app/modules/backend/templates/site/index.j2

@@ -125,6 +125,7 @@
                                         {% if not user.approved %}
                                         <a class="dropdown-item" href="{{ url_for('backend_user.approve', user_id=user.id) }}">Approve</a>
                                         {% endif %}
+                                        <a class="dropdown-item" href="{{ url_for('backend_user.remove', user_id=user.id) }}">Remove</a>
                                     </div>
                                 </div>
                             </td>

+ 1 - 1
app/templates/layout/page.j2

@@ -1,6 +1,6 @@
 {% extends "layout/public.j2" %}
 {% block head %}
-<title>{{ page.title }} - Democratic Assembly</title>
+<title>{{ page.title }} - pacc.gq</title>
 {% endblock %}
 {% block content %}
 {{ page.content() }}