Exemplo n.º 1
0
def trigger_current_project(data):
    """ if wednesday, count up interest in each project and trigger the one with the most """
    from datetime import datetime
    if not datetime.today().strftime('%A') == 'Wednesday':
        data['load_buttons'] = True
        return data
    data['load_buttons'] = False
    projects = data['projects']
    most_participants = 0
    current_project = None
    for project_dict in projects:
        project = Project(**project_dict)
        # make sure there's only one current project by resetting them all to inactive
        project.active = False
        
        project.save()
        data, project_dict = fill_and_count_participants(data, project_dict)
        if project_dict.get('participant_count') > most_participants:
            if hasattr(project, 'contributors'):
                project.contributors = []            
            most_participants = project_dict.get('participant_count')
            project.contributors = project_dict['participants']
            project.active = True
            project.save()    
            data['current_project'] = project_dict                

    return data
Exemplo n.º 2
0
def get_image(id):
    project = Project.objects(id=id).first()
    image = project.image
    if image:
        return send_file(image, mimetype="image")
    else:
        return "405"
Exemplo n.º 3
0
    async def post(self):
        # Добавление проектов в список истекших
        session = await get_session(self)
        user = session['user']
        data = await self.post()
        location = self.app.router['viewproject'].url_for()
        user_is_author = await Project.user_is_author(self.app['db'],
                                                      int(data['project_id']),
                                                      user['id'])

        if data['project_id'] and user_is_author:
            project = await Project.get_projects_by_id(self.app['db'],
                                                       int(data['project_id']))

            add_total = Project.add_total(self.app['db'],
                                          int(data['project_id']))
            location = self.app.router['results'].url_for()
            return web.HTTPFound(location=location)

        return web.HTTPFound(location=location)
Exemplo n.º 4
0
def update_project_by_id(id):
    project = Project.get_by_id(id)
    if not project:
        return jsonify({
            'status': 'error',
            'message': 'project could not be updated'
            }), 400
    f = request.form
    project = Project(**project)
    interested = f.get('interested')
    not_interested = f.get('not-interested')
    if f.get('owner'):
        owner_name, owner_id = f.get('owner').split(':')
        project.owner_name = owner_name
        project.owner_id = owner_id
    if not interested in project.interested:
        project.interested.append(interested)
    if not_interested in project.interested:
        project.interested.remove(not_interested)
    project.save()
    return jsonify({
        'status': 'OK', 'project': project.to_dict()
        }), 200
Exemplo n.º 5
0
def all_projects():
    if request.method == 'POST':
        from models.auth import Auth
        current_user = Auth.get_current_user()
        f = request.form
        name = f.get('name')
        if Project.get_by_attr('name', name):
            return jsonify({'status': 'error', 'project': ''}), 400
        data = {
            'name': f.get('name'),
            'call_to_action': f.get('call_to_action'),
            'feature_backlog': f.get('feature_backlog'),
            'minimal_version': f.get('minimal_version'),
            'stretch_goals': f.get('stretch_goals')
        }
        new_project = Project(**data)
        new_project.save()
        return jsonify({'status': 'OK', 'project': new_project.to_dict()}), 200
    projects = Project.get_by_class()
    if len(projects) == 0:
        return jsonify({'status': 'error', 'projects': []}), 400
    return jsonify({'status': 'OK', 'projects': projects}), 200
Exemplo n.º 6
0
    def post(self, user_id):
        fields = ("name", "length_overall", "length_perpendiculars", "breadth", "draft")
        args = init_args(fields)

        user = User.query.filter_by(id=user_id).first()

        if not user:
            response = {"message": "Usuário não existe"}

            return response, 400, {}

        name = Project.query.filter_by(name=args.name).first()

        if name:
            response = {"message": "Ja existe um projeto com esse nome"}

            return response, 409, {}

        new_project = Project(**args, user_id=user_id)

        db.session.add(new_project)
        db.session.commit()

        return new_project, 201, {}
Exemplo n.º 7
0
    KeyValue("Flask", "80%"),
    KeyValue("Flask-WTForms", "85%"),
    KeyValue("Flask-SQLAlchemy", "85%"),
    KeyValue("Axios", "80%"),
    KeyValue("PostgreSQL", "75%"),
    KeyValue("Pandas Python", "75%"),
    KeyValue("Heroku", "70%"),
    KeyValue("Django", "70%"),
    KeyValue("Big-O Notation", "70%"),
    KeyValue("jQuery", "65%"),
    KeyValue("Express", "35%")
]

projects = [
    Project("Meads' Meal-kit Planner", "Python, SQL, HTML, CSS, JavaScript",
            "../static/mealPlannerLogo.jpg",
            "https://meads-meal-planner-app.herokuapp.com/"),
    Project("JeoTool/Game Show Creator", "Node, React, SQL, HTML, CSS",
            "../static/jeotool.png", "https://jeotool.herokuapp.com/"),
    Project("Guess The Capital", "HTML, CSS, JavaScript",
            "../static/guessthatcapitalLogo.jpg",
            "https://ameads21.github.io/guess-the-capital/"),
    Project("Ward Website", "Python, SQL, HTML, CSS, JavaScript",
            "../static/zoom.jpg", "https://ch12ward.herokuapp.com/"),
    Project("Conquest", "GML", "../static/conquestLogo.jpg",
            "https://ameads21.github.io/conquest/")
]


def flash_errors(form):
    # flash("testing", "danger")
Exemplo n.º 8
0
 def setUp(self):
     self.firestore_client = FirestoreClient()
     self.project = Project()