Ejemplo n.º 1
0
    def __init__(self,
                 url: str,
                 title: str,
                 model: Model,
                 collection: Collection = None,
                 objectid: bool = True):
        self.url = url
        self.title = title
        self.model = model
        self.collection = db[url] if collection is None else collection
        self.objectid = objectid

        app.add_url_rule(f"/{url}/",
                         endpoint=f"table_{url}",
                         view_func=self.view_table)
        app.add_url_rule(f"/{url}/<item>",
                         endpoint=f"item_{url}",
                         view_func=self.view_item)
        app.add_url_rule(f"/{url}/<item>/edit",
                         endpoint=f"edit_{url}",
                         view_func=self.edit_item,
                         methods=["GET", "POST"])
        app.add_url_rule(f"/{url}/add",
                         endpoint=f"add_{url}",
                         view_func=self.add_item,
                         methods=["GET", "POST"])
Ejemplo n.º 2
0
from server import app

from controller.view import *
from controller.login import *
from controller.system import *
from controller.activate import *

app.add_url_rule('/', view_func=index, methods=['GET'], strict_slashes=False)
app.add_url_rule('/faq', view_func=faq, methods=['GET'], strict_slashes=False)
app.add_url_rule('/feedback',
                 view_func=feedback,
                 methods=['GET', 'POST'],
                 strict_slashes=False)
app.add_url_rule('/payment',
                 view_func=payment,
                 methods=['GET'],
                 strict_slashes=False)
app.add_url_rule('/access_denied',
                 view_func=access_denied,
                 methods=['GET'],
                 strict_slashes=False)
app.add_url_rule('/guide',
                 view_func=guide,
                 methods=['GET'],
                 strict_slashes=False)

app.add_url_rule('/friends/all',
                 view_func=friends_all,
                 methods=['GET'],
                 strict_slashes=False)
#app.add_url_rule('/friends/new', view_func=friends_new, methods=['GET'], strict_slashes=False)
Ejemplo n.º 3
0
        if len(set(['name', 'cost', 'payer', 'buyins']) &
               set([x for x in data])) == 4:

            # Validate that users involved have accounts

                # Extract payer id
            payer = User.objects(username=data['payer'])
            payer_id = payer[0].id

                # Extract ids of those who buy in
            buyins = User.objects(username__in=data['buyins'])
            buyin_ids = map(lambda x: x.id, buyins)

            purchase = Purchase(name=data['name'],
                                cost=data['cost'],
                                payer=payer_id,
                                buyins=buyin_ids,
                                time=datetime.datetime.now())
            purchase.save()

            debt_up_to_date = self.updateDebt(purchase)

            return jsonify({'res': True,
                            'messsage': 'Purchase added',
                            'debts': debt_up_to_date})
        return jsonify({'res': False,
                        'message': 'default'})

app.add_url_rule('/users/', view_func=UserAPI.as_view('users'))
app.add_url_rule('/purchases/', view_func=PurchaseAPI.as_view('purchases'))
Ejemplo n.º 4
0
from server import app

from server.controllers.home_controller import HomeController
from server.controllers.login_controller import LoginController, LogoutController
from server.controllers.register_controller import RegisterController
from server.controllers.schedule_controller import ScheduleController
from server.controllers.course.search_controller import CourseSearchController, CourseEnrollingController
from server.controllers.course.enrolled_controller import CoursesEnrolledController, CourseDroppingController
from server.controllers.program.enrolled_controller import ProgramsEnrolledController

# Home page
home_view = HomeController.as_view('index')
app.add_url_rule('/', view_func=home_view)
app.add_url_rule('/home', view_func=home_view)

# Login and logout
app.add_url_rule('/login', view_func=LoginController.as_view('login'))
app.add_url_rule('/logout', view_func=LogoutController.as_view('logout'))

# Register
app.add_url_rule('/register', view_func=RegisterController.as_view('register'))

# Schedule page
app.add_url_rule('/schedule', view_func=ScheduleController.as_view('schedule'))

# Enrolled courses page
enrolled_courses_view = CoursesEnrolledController.as_view('courses_enrolled')
app.add_url_rule('/courses', view_func=enrolled_courses_view)
app.add_url_rule('/courses/enrolled', view_func=enrolled_courses_view)

# Enrolling in courses
Ejemplo n.º 5
0
"""
Author      : Akash Sundaresh
Date        : 08-12-2019
Description : 
"""

from server import app
from .views.user_view import UserView
from .views.room_view import RoomView

# Defining the view once, as multiple urls can point to same view.
user_view = UserView.as_view('user_api')
room_view = RoomView.as_view('room_api')

# Declare all URLs after the views are defined
app.add_url_rule('/users', view_func=user_view)
app.add_url_rule('/users/<user_email>', view_func=user_view)

app.add_url_rule('/rooms', view_func=room_view)
app.add_url_rule('/rooms/<email>', view_func=room_view)
Ejemplo n.º 6
0
from server import app

import controllers.auth as auth
import controllers.api as api
import controllers.view as view

app.add_url_rule('/',
                 view_func=view.index,
                 methods=['GET'],
                 strict_slashes=False)
app.add_url_rule('/find',
                 view_func=api.find,
                 methods=['GET'],
                 strict_slashes=False)
Ejemplo n.º 7
0
        olympiads = Olympiad.objects.all()

        if user.is_anonymous():
            return render_template('olympiads.html', olympiads=olympiads)
        else:
            return render_template('olympiads.html', olympiads=olympiads, user=user)
    
    
class Login(MethodView):
    def get(self):
        return render_template('signin.html')

    def post(self):
        username = request.form['username']
        password = request.form['password']

        user = get_user(username, password)

        if user is not None:
            remember = 'remember-me' in request.form
            if login_user(user, remember=remember):
                #flash(request.args['next'])
                return redirect(request.args['next'])
                #return redirect(url_for('index'))

        return render_template('signin.html')


app.add_url_rule('/olympiads/', view_func=Olympiads.as_view('olympiads'))
app.add_url_rule('/login', view_func=Login.as_view('login'))