ooiservices/app/redmine/routes.py
def create_redmine_ticket_for_notification(project_id, subject, description, priority, assigned_id):
    """ Create a redmine ticket for an alert notification.
    """
    ticket_id = None

    # Define required and recommended ticket fields
    required_fields = ['project_id', 'subject']
    recommended_fields = ['due_date', 'description', 'priority_id', 'assigned_to_id',
                          'start_date', 'estimated_hours', 'status_id', 'notes',
                          'tracker_id', 'parent_issue_id', 'done_ratio']
    try:
        data = {
                'project_id': project_id,
                'subject':  subject,
                'description': description,
                'priority_id': priority,
                'assigned_to_id': assigned_id,
                'category_id':  1
                }
        fields = dict()
        for field in required_fields + recommended_fields:
            if field in data:
                fields[field] = data[field]

        # Log into Redmine
        redmine = redmine_login()
        issue = redmine.issue.new()
        # Get the list of ticker Trackers
        trackers = list(redmine.tracker.all())
        # Find the REDMINE_TRACKER (like 'Support') and get the id
        # This make a difference for field validation and proper tracker assignment
        config_redmine_tracker = current_app.config['REDMINE_TRACKER']
        tracker_id = [tracker.id for tracker in trackers if tracker.name == config_redmine_tracker][0]
        issue.tracker_id = tracker_id # support
        for key, value in fields.iteritems():
            setattr(issue, key, value)

        if issue.save():
            ticket_id = issue.id

    except Exception as err:
        current_app.logger.exception('[create_redmine_ticket_for_notification] %s ' % err.message)

    finally:
        return ticket_id
 Create a redmine ticket for an alert notification.
    
Create a redmine ticket for an alert notification.
Create a redmine ticket for an alert notification .
def create_redmine_ticket_for_notification(project_id, subject, description, priority, assigned_id):
    ticket_id = None
    required_fields = ['project_id', 'subject']
    recommended_fields = ['due_date', 'description', 'priority_id', 'assigned_to_id',
                          'start_date', 'estimated_hours', 'status_id', 'notes',
                          'tracker_id', 'parent_issue_id', 'done_ratio']
    try:
        data = {
                'project_id': project_id,
                'subject':  subject,
                'description': description,
                'priority_id': priority,
                'assigned_to_id': assigned_id,
                'category_id':  1
                }
        fields = dict()
        for field in required_fields + recommended_fields:
            if field in data:
                fields[field] = data[field]
        redmine = redmine_login()
        issue = redmine.issue.new()
        trackers = list(redmine.tracker.all())
        config_redmine_tracker = current_app.config['REDMINE_TRACKER']
        tracker_id = [tracker.id for tracker in trackers if tracker.name == config_redmine_tracker][0]
        issue.tracker_id = tracker_id 
        for key, value in fields.iteritems():
            setattr(issue, key, value)
        if issue.save():
            ticket_id = issue.id
    except Exception as err:
        current_app.logger.exception('[create_redmine_ticket_for_notification] %s ' % err.message)
    finally:
        return ticket_id
def create_redmine_ticket_for_notification ( project_id , subject , description , priority , assigned_id ) : ticket_id = None required_fields = [ 'project_id' , 'subject' ] recommended_fields = [ 'due_date' , 'description' , 'priority_id' , 'assigned_to_id' , 'start_date' , 'estimated_hours' , 'status_id' , 'notes' , 'tracker_id' , 'parent_issue_id' , 'done_ratio' ] try : data = { 'project_id' : project_id , 'subject' : subject , 'description' : description , 'priority_id' : priority , 'assigned_to_id' : assigned_id , 'category_id' : 1 } fields = dict ( ) for field in required_fields + recommended_fields : if field in data : fields [ field ] = data [ field ] redmine = redmine_login ( ) issue = redmine . issue . new ( ) trackers = list ( redmine . tracker . all ( ) ) config_redmine_tracker = current_app . config [ 'REDMINE_TRACKER' ] tracker_id = [ tracker . id for tracker in trackers if tracker . name == config_redmine_tracker ] [ 0 ] issue . tracker_id = tracker_id for key , value in fields . iteritems ( ) : setattr ( issue , key , value ) if issue . save ( ) : ticket_id = issue . id except Exception as err : current_app . logger . exception ( '[create_redmine_ticket_for_notification] %s ' % err . message ) finally : return ticket_id
Create a redmine ticket for an alert notification.
Create a redmine ticket for an alert notification .
""" Create a redmine ticket for an alert notification.
    """ # Define required and recommended ticket fields # Log into Redmine # Get the list of ticker Trackers # Find the REDMINE_TRACKER (like 'Support') and get the id # This make a difference for field validation and proper tracker assignment # support
project_id
subject
description
priority
assigned_id