コード例 #1
0
ファイル: views.py プロジェクト: suzifarkash/mentors-backend
def technologies():
    if request.method == 'GET':
        return {'technologies': [t.name for t in Technology.select()]}
    else:
        technologies_str = request.form.get('technologies', '')
        technologies_list = [t.strip() for t in technologies_str.split(',')]
        inserted = Technology.insert_many([{'name': tech}
                                           for tech in technologies_list]).returning().on_conflict_ignore().execute()
        return '{} technologies inserted'.format(inserted)
コード例 #2
0
    def post(self):
        form = TechnologyForm(self.request.POST)

        if form.validate():
            title = form.data["title"]
            slug = title.strip().lower().replace(" ", "-")
            technology = Technology(title = title, slug = slug)
            technology.put()
        else:
            print form.errors

        self.redirect_to('admin-projects-technologies')
コード例 #3
0
ファイル: code.py プロジェクト: ozw1z5rd/gdg-pescara
 def t000_Technology(self):
     """Lista delle tecnologie"""
     L.i("TecnologyTestData load start")
     c = 0
     for el in TestData.listTechnologies:
         L.i("    Dataloaded #{0}".format(c))
         c += 1
         technology = Technology(title=el['title'],
                                 description=el['description'],
                                 icon="nunce")
         self.technologyEntity.append(technology)
         technology.put()
     L.i("TechnologyTestData load ended")
     return True
コード例 #4
0
ファイル: code.py プロジェクト: ozw1z5rd/gdg-pescara
	def t000_Technology(self):
		"""Lista delle tecnologie"""
		L.i("TecnologyTestData load start")
		c = 0
		for el in TestData.listTechnologies:
			L.i("    Dataloaded #{0}".format(c)); c+=1;
			technology = Technology(
				title = el['title'],
				description=el['description'],
				icon="nunce")
			self.technologyEntity.append(technology)
			technology.put()
		L.i("TechnologyTestData load ended")
		return True
コード例 #5
0
    def get(self):
        technologies = Technology.all()

        return {
            "admin_section": "admin-projects-technologies",
            "technologies": technologies,
        }
コード例 #6
0
    def get(self):
        form = PortfolioProjectForm()
        form.technologies.choices = [(tech.key().id(), tech.title) for tech in Technology.all().fetch(None)]

        return {
            "admin_section": "admin-projects-new",
            "form": form,
        }
コード例 #7
0
    def get(self, project_id, extra=""):
        project = PortfolioProject.get_by_id(long(project_id))
        form = PortfolioProjectForm(obj = project)
        form.technologies.choices = [(tech.key().id(), tech.title) for tech in Technology.all().fetch(None)]

        return {
            "admin_section": "admin-projects-portfolio",
            "form": form,
            "success": extra == "saved",
            "upload_url": blobstore.create_upload_url(webapp2.uri_for('image-upload')),
            "project": project,
        }
コード例 #8
0
    def post(self):
        form = PortfolioProjectForm(self.request.POST)
        form.technologies.choices = [(tech.key().id(), tech.title) for tech in Technology.all().fetch(None)]

        if form.validate():
            project = PortfolioProject(**form.data)
            project.save()
            self.redirect_to("admin-projects-edit-extra", project_id = project.key().id(), extra="saved")

        return {
            "admin_section": "admin-projects-new",
            "form": form,
        }
コード例 #9
0
def add_technology():
    form = AddTechnologyForm(request.form)
    if request.method == 'POST' and form.validate():
        technology = Technology(form.name.data)
        db.session.add(technology)
        db.session.commit()
        flash('Technology added', 'info')
        return redirect(url_for('add_technology'))
    return render_template('_add.html',
                           form=form,
                           rows=Technology.query.all(),
                           target_model="Technology",
                           fields=Technology.__mapper__.c.keys(),
                           action="addtechnology")
コード例 #10
0
ファイル: views.py プロジェクト: smallmeet/websth.com
def website_upload():
    postJson = json.loads(request.data)
    app.logger.debug(postJson)
    if not postJson.has_key('hostname'):
        return jsonify(status='missing hostname')

    technologies = []
    for t in postJson['technologies']:
        if not t.has_key('title'):
            return jsonify(status='missing technology title')
        if not t.has_key('category'):
            return jsonify(status='missing technology category')
        if not t.has_key('url'):
            t['url'] = None
        if not t.has_key('detail'):
            t['detail'] = None

        # 完全一致的技术
        tmpTech = Technology.query.filter_by(title=t['title']).filter_by(
            category=t['category']).filter_by(detail=t['detail']).first()
        if tmpTech is None:
            tmpTech = Technology(category=t['category'],
                                 title=t['title'],
                                 detail=t['detail'],
                                 url=t['url'])
            db.session.add(tmpTech)

        technologies.append(tmpTech)

    upload = Website.query.filter_by(hostname=postJson['hostname'],
                                     port=postJson['port']).first()
    if not upload:
        upload = Website(hostname=postJson['hostname'],
                         port=postJson['port'],
                         title=postJson['title'],
                         ipaddress=postJson['ipaddress'],
                         geo=postJson['geo'],
                         technologies=technologies)
    else:
        upload.last_time = datetime.now()
        upload.title = postJson['title']
        upload.technologies = technologies
        upload.ipaddress = postJson['ipaddress']
        upload.geo = postJson['geo']
        upload.frequency = upload.frequency + 1

    db.session.add(upload)
    db.session.commit()

    return jsonify(status='ok')
コード例 #11
0
    def post(self, technology_id):
        form = TechnologyForm(self.request.POST)

        if form.validate():
            slug = form.data["title"].strip().lower().replace(" ", "-")
            technology = Technology.get(long(category_id))
            form.populate_obj(technology)
            technology.put()

        return {
            "result": {
               "id": technology.key().id(),
               "title": technology.title,
               "slug": technology.slug,
           }
        }
コード例 #12
0
    def post(self, project_id, extra=""):
        project = PortfolioProject.get_by_id(long(project_id))
        form = PortfolioProjectForm(self.request.POST)
        form.technologies.choices = [(tech.key().id(), tech.title) for tech in Technology.all().fetch(None)]
        success = False

        if form.validate():
            form.populate_obj(project)
            project.save()
            success = True

        return {
            "admin_section": "admin-projects-portfolio",
            "form": form,
            "success": success,
            "project": project,
        }
コード例 #13
0
    def get(self, category=None, technology=None):
        cur_technology = cur_category = None
        categories = ProjectCategory.all()

        if category:
            cur_category = ProjectCategory.all().filter("slug =", category).get()
            projects = PortfolioProject.all().filter("category =", cur_category).order("-date_created")
        elif technology:
            cur_technology = Technology.all().filter("slug =", technology).get()
            projects = PortfolioProject.all().filter("technologies =", cur_technology.key()).order("-date_created")
        else:
            projects = PortfolioProject.all().order("-date_created")
            cur_category = None

        return {
            "section": "portfolio",
            "projects": projects,
            "cur_category": cur_category,
            "cur_technology": cur_technology,
            "categories": categories,
        }
コード例 #14
0
ファイル: views.py プロジェクト: Abdulkereem/Model
def addpost():
    posttype = request.form['posttype']
    post_title = request.form['posttitle']
    posted_by = request.form['postedby']
    location = request.form['postlocation']
    #file_attach = request.files['']
    content = request.form['content']

    email = current_user.email
    my_user = db.session.query(User).filter_by(email=email).first()
    if posttype == 'politics' and my_user.post_counter < 10 and my_user.daily_post < 10 and my_user.daily_post < 1000:
        post = Politics(post_type=posttype,
                        post_title=post_title,
                        posted_by=posted_by,
                        location=location,
                        content=content,
                        date_posted=datetime.now())
        db.session.add(post)
        email = current_user.email
        my_user = db.session.query(User).filter_by(email=email).first()
        if my_user is None:
            pass

        #counting =  my_user.post_counter + 1
        #counting =str(counting)
        my_user.post_counter += 1
        my_user.daily_post += 1
        my_user.user_balance += 100
        #my_user.post_counter=counts
        db.session.add(my_user)  #t
        db.session.commit()
        return "Posted" + posted_by

    #my_user.withdraw = "yes"
    #db.session.add(my_user) #t
    #db.session.commit()
    #return 'You no more eligiable please wait for the next 24hours and withdraw yor money'

    email = current_user.email
    my_user = db.session.query(User).filter_by(email=email).first()
    if posttype == 'general' and my_user.post_counter < 10 and my_user.daily_post < 10 and my_user.daily_post < 1000:
        post = General(post_type=posttype,
                       post_title=post_title,
                       posted_by=posted_by,
                       location=location,
                       content=content,
                       date_posted=datetime.now())
        db.session.add(post)
        db.session.commit()

        email = current_user.email
        my_user = db.session.query(User).filter_by(email=email).first()
        if my_user is None:
            pass

        #counting =  my_user.post_counter + 1
        #counting =str(counting)
        my_user.post_counter += 1
        my_user.daily_post += 1
        my_user.user_balance += 100
        #my_user.post_counter=counts
        db.session.add(my_user)  #t
        db.session.commit()
        return "Posted" + posted_by

    email = current_user.email
    my_user = db.session.query(User).filter_by(email=email).first()
    if posttype == 'entertainment' and my_user.post_counter < 10 and my_user.daily_post < 10 and my_user.daily_post < 1000:
        post = Entertainment(post_type=posttype,
                             post_title=post_title,
                             posted_by=posted_by,
                             location=location,
                             content=content,
                             date_posted=datetime.now())
        db.session.add(post)
        email = current_user.email
        my_user = db.session.query(User).filter_by(email=email).first()
        if my_user is None:
            pass

        #counting =  my_user.post_counter + 1
        #counting =str(counting)
        my_user.post_counter += 1
        my_user.daily_post += 1
        my_user.user_balance += 100
        #my_user.post_counter=counts
        db.session.add(my_user)  #t
        db.session.commit()
        return "Posted" + posted_by

    email = current_user.email
    my_user = db.session.query(User).filter_by(email=email).first()
    if posttype == 'sport' and my_user.post_counter < 10 and my_user.daily_post < 10 and my_user.daily_post < 1000:
        post = Sport(post_type=posttype,
                     post_title=post_title,
                     posted_by=posted_by,
                     location=location,
                     content=content,
                     date_posted=datetime.now())
        db.session.add(post)
        db.session.commit()
        return "Posted" + posted_by

    email = current_user.email
    my_user = db.session.query(User).filter_by(email=email).first()
    if posttype == 'tech' and my_user.post_counter < 10 and my_user.daily_post < 10 and my_user.daily_post < 1000:
        post = Technology(post_type=posttype,
                          post_title=post_title,
                          posted_by=posted_by,
                          location=location,
                          content=content,
                          date_posted=datetime.now())
        db.session.add(post)
        db.session.commit()

        email = current_user.email
        my_user = db.session.query(User).filter_by(email=email).first()
        if my_user is None:
            pass

        #counting =  my_user.post_counter + 1
        #counting =str(counting)
        my_user.post_counter += 1
        my_user.daily_post += 1
        my_user.user_balance += 100
        #my_user.post_counter=counts
        db.session.add(my_user)  #t
        db.session.commit()
        flash("Thank You Content Posted")
        return redirect(url_for('dashboard'))
    else:
        return 'post type is not selected or not available'
コード例 #15
0
def init_technologies(techs):
    Technology.insert_many([{'name': tech} for tech in techs]).execute()
コード例 #16
0
 def getList(self, request):
     technology = Technology()
     return list(technology.all())
コード例 #17
0
ファイル: controller.py プロジェクト: ozw1z5rd/gdg-pescara
	def getList(self,request):
		technology = Technology()
		return  list( technology.all() )