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.contrib import admin | |
from certificates.models import Certificate | |
@admin.register(Certificate) | |
class CertificateAdmin(admin.ModelAdmin): | |
list_display = ("certificate_number", "member_coyote_lakes_address", "name_associated_with_certificate", "is_for_sale", "is_for_sale_as_of_date", "is_club_held", "purchase_date", "certificate_notes", "created", "updated") | |
search_fields = ["certificate_number", "member_coyote_lakes_address__route","member_coyote_lakes_address__street_number", "name_associated_with_certificate__user__last_name", "name_associated_with_certificate__user__first_name", "certificate_notes"] | |
list_filter = ("is_for_sale", "is_for_sale_as_of_date", "is_club_held") | |
def get_form(self, request, obj=None, **kwargs): | |
form = super(CertificateAdmin, self).get_form(request, obj, **kwargs) |
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 import forms | |
from .models import Interface | |
class DeviceAdminForm(forms.ModelForm): | |
def clean(self): | |
cleaned_data = super().clean() | |
hostname = cleaned_data.get("hostname") | |
if not hostname: |
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 React, { Component } from 'react' | |
import Select from 'react-select' | |
import axios from 'axios' | |
import {Bar} from 'react-chartjs-2' | |
import './App.css' | |
export default class App extends Component { | |
constructor(props){ | |
super(props) |
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
def save(self, *args, **kwargs): | |
if self.device_a and self.interface_a: | |
if self.device_a.hostname == self.interface_a.device.hostname: | |
raise ValidationError( | |
_("No two interfaces belonging to the same device may be connected. Your selection of Interface A shares the same Device as your Device A selection."), code='invalid' | |
) | |
if self.device_b and self.interface_b: | |
if self.device_b.hostname == self.interface_b.device.hostname: |
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 ConnectionSerializer(serializers.BaseSerializer): | |
class Meta: | |
model = Connection | |
fields = ['device_a', 'interface_a', 'device_b', 'interface_b'] | |
def to_internal_value(self, data): | |
device_a = data.get('device_a') | |
interface_a = data.get('interface_a') | |
device_b = data.get('device_b') | |
interface_b = data.get('interface_b') |
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 import forms | |
from .models import Interface | |
class DeviceAdminForm(forms.ModelForm): | |
def clean(self): | |
cleaned_data = super().clean() | |
hostname = cleaned_data.get("hostname") | |
if not hostname: |
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.test import TestCase | |
from django.urls import reverse | |
from transaction.models import Transaction | |
class ReportIndexViewTests(TestCase): | |
def test_report_index_loads_properly(self): | |
response = self.client.get(reverse('report:index')) | |
self.assertEqual(response.status_code, 200) |
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 sqlite3 | |
conn = sqlite3.connect('/Users/marci/Desktop/trails_rank/newtrails.sqlite') | |
cur = conn.cursor() | |
cur.execute('''SELECT * from addtrails''') | |
table_rows = cur.fetchall() | |
# update table with TRAIL_TYPE ranks. | |
cur.execute('''UPDATE addtrails SET t_t_rank = 5 WHERE TRAIL_TYPE IN |