This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import serializers | |
from django.contrib.auth.models import User | |
from tickets.models import Ticket, Category | |
# Serializers define the API representation. | |
class UserSerializer(serializers.HyperlinkedModelSerializer): | |
class Meta: | |
model = User | |
fields = ('url', 'username', 'email', 'is_staff') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
from rest_framework import routers, serializers, viewsets | |
from ticketapi.serializers import UserSerializer, TicketSerializer, CategorySerializer | |
from django.contrib.auth.models import User | |
from tickets.models import Ticket, Category | |
# Create your views here. | |
# ViewSets define the view behavior. | |
class UserViewSet(viewsets.ModelViewSet): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""ticketapi URL Configuration | |
The `urlpatterns` list routes URLs to views. For more information please see: | |
https://docs.djangoproject.com/en/2.0/topics/http/urls/ | |
Examples: | |
Function views | |
1. Add an import: from my_app import views | |
2. Add a URL to urlpatterns: path('', views.home, name='home') | |
Class-based views | |
1. Add an import: from other_app.views import Home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
import uuid | |
from django.contrib.auth.models import User | |
# Create your models here. | |
def generate_ticket_id(): | |
return str(uuid.uuid4()).split("-")[-1] #generate unique ticket id | |
class Ticket(models.Model): | |
title = models.CharField(max_length=255) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TicketSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = Ticket | |
fields = ('id','title', 'ticket_id','user', 'content', 'category','created', 'modified') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
import uuid | |
from django.contrib.auth.models import User | |
# Create your models here. | |
status = ( | |
("PENDING", "Pending"), | |
("CLOSED", "Closed"), | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import serializers | |
from django.contrib.auth.models import User | |
from tickets.models import Ticket, Category | |
# Serializers define the API representation. | |
class UserSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = User | |
fields = ('id', 'username', 'email', 'is_staff') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import click | |
import requests | |
__author__ = "Oyetoke Toby" | |
@click.group() | |
def main(): | |
""" | |
Simple CLI for querying books on Google Books by Oyetoke Toby | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function, unicode_literals | |
from PyInquirer import style_from_dict, Token, prompt, Separator | |
from pprint import pprint | |
style = style_from_dict({ | |
Token.Separator: '#cc5454', | |
Token.QuestionMark: '#673ab7 bold', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import print_function, unicode_literals | |
import regex | |
from pprint import pprint | |
from PyInquirer import style_from_dict, Token, prompt | |
from PyInquirer import Validator, ValidationError | |
OlderNewer