Ejemplo n.º 1
0
def welcome():
    user_db = auth.current_user_db()
    today = datetime.date.today()
    week_start = today - timedelta(days=today.weekday())
    week_end = week_start + timedelta(days=6)

    # list_keys = list_query.fetch(keys_only=True)  # maybe put a limit here.
    #
    # list_keys = random.sample(list_keys, 20)
    # issue_dbs = [list_key.get() for list_key in list_keys]
    user_issues = []
    if user_db is not None:
        if user_db.series_list:
            for serie in user_db.series_list:
                serie_6_issues = Issue.query(Issue.serie == serie).order(-Issue.date).fetch(limit=6)
                user_issues += serie_6_issues
            # if user_db.buy_list:
            #     current_week += Issue.query(Issue.key.IN(user_db.buy_list))
            #
            # next_weeks = Issue.query(
            #     ndb.AND(Issue.serie.IN(user_db.series_list),
            #             Issue.date > week_end
            #             )
            # ).order(Issue.date).fetch()
    # for issue in user_issues:
    #     print(issue.title.encode())
    return flask.render_template('welcome.html',
                                 html_class='welcome',
                                 user_db=user_db,
                                 user_issues=user_issues,
                                 )
Ejemplo n.º 2
0
    def get(self, title):
        serie = Serie.get_by_id(title)
        if not serie:
            helpers.make_not_found_exception('Serie %s not found' % title)

        issues = Issue.query(Issue.serie == serie.key).fetch()
        return helpers.make_response(issues, model.Issue.FIELDS)
Ejemplo n.º 3
0
def issue_page(title):
    title = urllib.unquote_plus(title)
    issues = Issue.query(Issue.title == title).fetch()
    for issue in issues:
        if len(issue.summary) == 0:
            parser = Parser()
            parser.parse_issue_summary(issue)
    return flask.render_template('issue_page.html', issues=issues)
Ejemplo n.º 4
0
 def parse_issue(self, issue: dict) -> Issue:
     labels = [label['name'] for label in issue['labels']]
     return Issue(
         id=issue['number'],
         title=issue['title'],
         url=issue['html_url'],
         date=issue['created_at'],
         labels=labels)
Ejemplo n.º 5
0
 def get_issues(self, state='open') -> List:
     """
     :param state: Issue state: 'open', 'closed', 'all'.
     :return: Issues.
     """
     return [
         Issue(**d)
         for d in self.get_result(self.path + conf.ISSUES, state=state)
     ]
Ejemplo n.º 6
0
def cart_page():
    user_db = auth.current_user_db()
    cart = []
    if user_db.cart:
        cart = Issue.query(Issue.key.IN(
            user_db.cart)).order(-Issue.date).fetch()
    else:
        flask.abort(404)
    return flask.render_template('cart_page.html', cart=cart, user_db=user_db)
Ejemplo n.º 7
0
def purchased_page():
    user_db = auth.current_user_db()
    purchased = []
    if user_db.purchased_list:
        purchased = Issue.query(Issue.key.IN(
            user_db.purchased_list)).order(-Issue.date).fetch()
    else:
        flask.abort(404)
    return flask.render_template('purchased_page.html',
                                 purchased=purchased,
                                 user_db=user_db)
Ejemplo n.º 8
0
def purchased_list_del():
    title = request.form['issue_title']
    issue = Issue.query(Issue.title == title).get(keys_only=True)
    user_db = auth.current_user_db()
    if (issue is not None) & (issue in user_db.purchased_list):
        user_db.purchased_list.remove(issue)
        user_db.put()
        app.logger.debug("issue removed from purchased list: %s" % title)
    else:
        app.logger.error("issue %s not found" % title)
    return flask.redirect(flask.url_for('purchased_page'))
Ejemplo n.º 9
0
    def get(self, title):
        issue = Issue.get_by_id(title)
        if not issue:
            helpers.make_not_found_exception('Issue %s not found' % title)
        if len(issue.summary) == 0:
            parser = Parser()
            parser.parse_issue_summary(issue)

        return flask.jsonify({
            'result': issue.summary,
            'status': 'success',
        })
Ejemplo n.º 10
0
def serie_page(title):
    user_db = auth.current_user_db()
    serie = []
    if title:
        serie = Issue.query(
            Issue.serie == ndb.Key(Serie, title)).order(-Issue.date).fetch()
    if not serie:
        abort(404)
    return flask.render_template('serie_page.html',
                                 title=title,
                                 serie=serie,
                                 user_db=user_db)
Ejemplo n.º 11
0
def cart_add():
    title = request.form['issue_title']

    issue = Issue.query(Issue.title == title).get(keys_only=True)
    app.logger.debug("%s" % issue)
    user_db = auth.current_user_db()
    if (issue is not None) & (issue not in user_db.cart):
        user_db.cart.append(issue)
        user_db.put()
        app.logger.debug("issue added to cart: %s" % title)
    else:
        app.logger.error("user: %s \tissue %s not found" %
                         (user_db.name, title))
    return flask.redirect(flask.url_for('welcome'))
Ejemplo n.º 12
0
 def parse_file(path: str) -> List[Issue]:
     issues: List[Issue] = []
     tree: et = et.parse(path)
     root: et = tree.getroot()
     if root.tag != "Issues":
         return []
     for issue in root:
         if issue.tag == "Issue":
             issue_attribs = issue.attrib
             if "name" not in issue_attribs and "rating" not in issue_attribs:
                 continue
             _issue = Issue(issue.attrib["name"])
             _issue.rating = int(issue_attribs["rating"])
             for option in issue:
                 if option.tag == "Option":
                     option_attribs = option.attrib
                     if "name" not in option_attribs and "rating" not in option_attribs:
                         continue
                     _option = Option(option_attribs["name"])
                     _option.rating = int(option_attribs["rating"])
                     _issue.add_option(_option)
             issues.append(_issue)
     return issues
Ejemplo n.º 13
0
def all_series():
    user_db = auth.current_user_db()
    issues = []
    series = Serie.query().fetch(keys_only=True)
    if not series:
        abort(404)
    for serie in series:
        serie_6_issues = Issue.query(
            Issue.serie == serie).order(-Issue.date).fetch(limit=6)
        issues += serie_6_issues

    return flask.render_template('all_series_page.html',
                                 series=series,
                                 user_db=user_db,
                                 issues=issues)
Ejemplo n.º 14
0
 def storeIssue(self, repo, issueData, updateTime = None):
     """Update database with issue data"""
     number = issueData['number']
     issue = repo.issue(number)
     if 'modified_at' in issueData and not updateTime:
         updateTime = issueData['modified_at']
     if not issue:
         issue = Issue(repo = repo.key, number = number)
     issue.github = self.issue(repo, number, issue.github)
     issue.githubUpdate = updateTime
     issue.zenhubUpdate = None  # mark for Zenhub update
     logging.info("Upserting issue %s" % issue.number)
     issue.upsert()
Ejemplo n.º 15
0
    def save_issue(self, item):
        """
        Saves the parsed issue into the database

        :param item: parsed issue
        """
        app.logger.debug("saving the issues")
        issue = Issue(id=item['title'])
        issue.title = item['title']
        if 'subtitle' in item:
            if any(word in item['subtitle'].split()
                   for word in ["variant", "Variant"]):
                issue.key = ndb.Key(Issue, item['title'] + " variant")
                app.logger.debug("found variant, new issue id is " +
                                 item['title'] + " variant")
            issue.subtitle = item['subtitle']

        if 'serie' in item:
            keyname = item['serie'].rstrip('1234567890 ')
            serie = Serie.get_or_insert(keyname, title=keyname)
            issue.serie = serie.key

        if 'reprint' in item:
            issue.reprint = item['reprint']

        if 'url' in item:
            issue.url = item['url']

        if 'summary' in item:
            issue.summary = item['summary']

        if 'date' in item:
            issue.date = item['date']

        if 'price' in item:
            issue.price = item['price']

        if "placeholder/default/no-photo" in item['image']:
            issue.image = item['image']
        else:
            issue.image = item['image'].replace('small_image/200x', 'image')

        issue.put_async()
        app.logger.debug("issue " + issue.title + " saved")
Ejemplo n.º 16
0
    logger.info("Cloning issues for version %s", version.name if version else '-')

    if version:
        issues = soap.getIssuesFromJqlSearch(auth,
            "project = %s and fixVersion = '%s'" % (project_name, version.name),
            SOAPpy.Types.intType(1000))
    else:
        issues = soap.getIssuesFromJqlSearch(auth,
            "project = %s and fixVersion is EMPTY" % project_name,
            SOAPpy.Types.intType(1000))

    for issue in issues:
        if int(issue.id) in existing_issues:
            issue_model = session.query(Issue).get(int(issue.id))
        else:
            issue_model = Issue(id=int(issue.id))

        issue_model.key=issue.key
        issue_model.type=issue_types[issue.type].name
        issue_model.subtask=issue_types[issue.type].subTask
        issue_model.summary=issue.summary
        issue_model.assignee=issue.assignee
        issue_model.created_at=datetime(*issue.created)
        issue_model.status = statuses[int(issue.status)]
        if version:
            issue_model.fix_version = version_model
        else:
            issue_model.fix_version = None

        if issue.duedate:
            issue_model.due_date = datetime(*issue.duedate)
Ejemplo n.º 17
0
    def get(self, title):
        issue = Issue.get_by_id(title)
        if not issue:
            helpers.make_not_found_exception('Issue %s not found' % title)

        return flask.redirect(issue.image)
Ejemplo n.º 18
0
 def get(self, title):
     issue = Issue.get_by_id(title)
     if not issue:
         helpers.make_not_found_exception('Issue %s not found' % title)
     app.logger.info("issue found: %s" % title)
     return helpers.make_response(issue, model.Issue.FIELDS)