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
get_data_mock.return_value = { | |
'numbers': [ | |
{'number': '123234', 'type': 'Application Number'}, | |
{'number': '324345', 'type': 'Application Filed'}, | |
], | |
'classes': [ | |
{'number': '004', 'description': 'class'} | |
], | |
"contacts": [ | |
{"type": "applicant", "name": "Guilin HBM Healthcares,Inc. ", "email": ""} |
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
# @receiver(post_save, sender=User) | |
# def create_organization(instance, created, **kwargs): | |
# if created: | |
# title = str(instance) | |
# code = re.sub('[\W_]+', '', title.upper())[:3] | |
# Organization.objects.create(owner=instance, title=title, code=code) |
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 _render_ref_no(self, template): | |
""" | |
Renders template provided in the string.Template format. Uses output of *TemplateSerializer as the template's | |
context. | |
""" | |
ref_no_template = Template(template) | |
from legal.api.serializers import MatterTemplateSerializer, SubMatterTemplateSerializer | |
srlzr = MatterTemplateSerializer if isinstance(self, Matter) else SubMatterTemplateSerializer |
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 detail(request, company_slug, template_name="companies/detail.html"): | |
office = get_object_or_404(CompanyOffice, slug=company_slug) | |
if not (office.active and office.is_subscribed) and request.user != office.user: | |
raise PermissionDenied() | |
followers = Following.objects.followers(office) |
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
@ajax_login_required | |
def share_content(request): | |
if request.method == 'POST': | |
model = request.POST.get('model').split('.') | |
Model = get_model(model[0], model[1]) | |
shared_object = Model.objects.get(pk=request.POST.get('pk')) | |
queryset_companies = _get_company_queryset(shared_object=shared_object) | |
form = ShareContentForm(queryset=queryset_companies, data=request.POST) |
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 _get_company_queryset(shared_object): | |
queryset_companies = CompanyOffice.objects.filter(~Q(pk__in=shared_object.shared_to.all().values('pk')), company=shared_object.office.company) | |
return queryset_companies |
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 forwards(self, orm): | |
project_ct = orm['contenttypes.ContentType'].objects.get(app_label="pekama", model="project") | |
with orm.Folder.objects.disable_mptt_updates(): | |
def assign_folder(project): | |
if project is None: | |
return project | |
try: | |
f = orm.Folder.objects.get(content_type=project.content_type, object_id=project.object_id) | |
f.content_type = project_ct |
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 Migration(DataMigration): | |
def forwards(self, orm): | |
for cr in orm['contacts.ContactRelation'].objects.all(): | |
project = orm['pekama.Project'].objects.get(content_type=cr.content_type, object_id=cr.object_id) | |
cr.project = project | |
cr.save() |
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 Migration(SchemaMigration): | |
depends_on = ( | |
('pekama', '0002_auto__add_project__chg_field_betasubscription_created__chg_field_betas'), | |
) | |
def forwards(self, orm): | |
# Adding field 'ContactRelation.project' | |
db.add_column(u'contacts_contactrelation', 'project', | |
self.gf('django.db.models.fields.related.ForeignKey')(default=1, to=orm['pekama.Project']), | |
keep_default=False) |
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.conf import settings | |
import requests | |
from requests.auth import HTTPBasicAuth | |
class UnsupportedFormat(requests.HTTPError): | |
pass | |
class Client(object): |
NewerOlder